调用Workligh适配器始终返回Android故障

时间:2015-11-06 20:00:19

标签: android ibm-mobilefirst worklight-adapters

我有一个片段活动,我想从中调用worklight过程。

适配器正在运行,我已在iOS上测试过,一切正常但是当我想从Android原生应用程序调用我的适配器时,我总是会失败。

这是我的代码

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);

}

似乎调用适配器没有任何问题,因为当我从onSuccess中移除进度对话框和所有内容并且失败时,每件事情都完美无缺,我得到了成功消息但是当我再次添加代码时,我得到了失败

我知道为什么在这种情况下会失败?

1 个答案:

答案 0 :(得分:1)

Worklight SDK不支持在片段中使用 有关此内容的详细信息,请参阅以下问题:Worklight App inside an Android Fragment