Reputation: 3876
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?
Upvotes: 1
Views: 87
Reputation: 44516
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
Upvotes: 1