1
votes

i have a fragment activity and i want to invoke worklight procedure from it.

the adapter is working and i have tested it on iOS and everything is ok but when i want to call my adapter from android native app i always get Failure.

That's my code

public class Login extends FragmentActivity implements ConnectionDelegate 


  callProcedure = new WLCallProcedure(Login.this);
    callProcedure.setConnectionDelegate(this);
    callProcedure.setAdapterName("portalAdapter");
    callProcedure.setProcedureName("forgetPassword");
    forget.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            if (email.getText().toString().equalsIgnoreCase("")) {
                Email_txt.setText(getResources().getString(R.string.plaese_enter_email));
                Email_txt.setTextColor(Color.RED);
                email.setBackgroundResource(R.drawable.roundedallsides_hares_red);
            } else {
                if (isValidEmail(email.getText().toString())) {

                    Email_txt.setText(getResources().getString(R.string.email_addrress));
                    Email_txt.setTextColor(Color.BLACK);
                    email.setBackgroundResource(R.drawable.roundedallsides_hares);
                    callProcedure.setInputParams(new Object[]{email.getText().toString()});
                    callProcedure.callProcedure();
                   // progressDialog.show();

                } else {


                    Email_txt.setText(getResources().getString(R.string.email_not_valid));
                    Email_txt.setTextColor(Color.RED);
                    email.setBackgroundResource(R.drawable.roundedallsides_hares_red);


                }


            }

        }
    });  


 @Override
public void OnSuccess() throws JSONException, IOException {
    String response = MyInvokeListener.successResponse;
    System.out.println("forgot success" + response);
    progressDialog.dismiss();
    if (response.indexOf("User Not Found") == -1) {
        Intent i = new Intent();
        i.putExtra("status", 0);

        setResult(RESULT_OK, i);
        finish();

        overridePendingTransition(R.anim.defff, R.anim.bottom_out);
    } else {
        Intent i = new Intent();

        i.putExtra("status", 1);

        setResult(RESULT_OK, i);
        finish();

        overridePendingTransition(R.anim.defff, R.anim.bottom_out);
    }

}

@Override
public void OnFailure(String error) {
    System.out.println("forgot error" + error);
    progressDialog.dismiss();
    Intent i = new Intent();

    i.putExtra("status", 2);

    setResult(RESULT_OK, i);
    finish();

    overridePendingTransition(R.anim.defff, R.anim.bottom_out);

}

It seems that there isn't any problem with invoking adapter because when i remove the progress dialog and every thing from onSuccess and on failure every things works perfectly and i got success message but when i add the code again i get failure

any idea why i get failure in this case?

1
you need to add more details, like what error are you getting, logcat, etc. - Yoel Nunez
I'm not getting any error just what i get "forgot error" which i print it on the fail callback - Antwan
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection W/IInputConnectionWrapper: getSelectedText on inactive InputConnection W/IInputConnectionWrapper: getTextAfterCursor on inactive InputConnection D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN D/WLDroidGap: Sending request appurl/Androidnative/query I/System.out: pool-4-thread-6 calls detatch() I/System.out: forgot error - Antwan
@YoelNunez that's what i got when i click forget button - Antwan
@Tony, do not keep your questions unanswered - we are still waiting to hear from you in stackoverflow.com/questions/32693750/… - either remove the question or answer to the questions in the comments section. - Idan Adar

1 Answers

1
votes

The Worklight SDK does not support usage in a Fragment.
For more information on this see the following question: Worklight App inside an Android Fragment