【问题标题】:Mobile First Native Android - Adapter not returning any resultMobile First Native Android - 适配器不返回任何结果
【发布时间】:2015-04-15 18:05:16
【问题描述】:

我正在关注 IBM (https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/hello-world/creating-first-native-android-mobilefirst-application/) 提供的文档

调用request.send(new MyInvokeListener()); 后没有成功或失败的回调。收到错误消息“Android Prototype 停止工作。”

当我右键单击适配器时,适配器工作正常 --> 运行方式 --> 调用移动优先适配器

下面是我的安卓原生代码。

public class TaskFeed extends AsyncTask<Void, Void, String> {

        ProgressDialog Dialog = new ProgressDialog(TaskActivity.this);



        @Override
        protected void onPreExecute() {
            Dialog.setMessage("Establishing connection...");
            Dialog.show();
        }

        @Override
        protected String doInBackground(Void... params) {

            try {
                final WLClient client = WLClient.createInstance(TaskActivity.this);
                client.connect(new MyConnectListener());

                URI adapterPath = new URI("/adapters/TaskAdapter/getAllTasks");

                WLResourceRequest request = new WLResourceRequest(adapterPath,WLResourceRequest.GET);


                request.send(new MyInvokeListener());

            } catch (Exception e) {
                e.printStackTrace();
            }
           // Dialog.setMessage("Loading Tasks..");
           return "test";
        }

        @Override

        protected void onPostExecute(String r) {



            Dialog.dismiss();

            ArrayList<ListViewModel> result = AssignAndGetCurrentTaskResults();
            tvListCount.setText(GetActionBarString());

            adapter = new ArrayDataAdapter(taContext, R.layout.task_row_item, result);
            listView.setAdapter(adapter);
            adapter.notifyDataSetChanged();

        }
    }

我的 InvokeListner 类

public class MyInvokeListener implements WLResponseListener {
        public void onSuccess(WLResponse response) {

            try {
                allTaskResults= ParseData(response.getResponseJSON().getJSONArray("array"));
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }

        }
        public void onFailure(WLFailResponse response) {

         }
    }

【问题讨论】:

  • 我在这里遗漏了什么吗?您没有打印来自 onFailure 的响应,那么为什么会看到失败?打印响应:Log.i("mypoject",Failure: " + response.getErrorMsg());
  • 实际上,我在此处设置了一个断点,看看它是否被击中。
  • 听起来与 MFP 代码无关。
  • 以下是来自 logcat E/AndroidRuntime 的信息:致命异常:pool-3-thread-4 进程:com.vdot.androidprototype,PID:21242 java.lang.Error: java.io.EOFException在 com.worklight.common.security.WLCertManager.loadKeystore(WLCertManager.java:457) 在 com.worklight.common.security.WLCertManager.getKeyPair(WLCertManager.java:436) 在 com.worklight.common.security.WLOAuthCertManager.getKeyPair (WLOAuthCertManager.java:89)
  • 显然你在你的应用程序中做了一些事情,你没有提到这个问题。详细说明您的应用程序、场景、其设置是否有任何特殊之处、是否涉及任何安全性......也可以尝试使用仅执行调用的新应用程序 - 就像示例中一样。示例是否有效?

标签: java android ibm-mobilefirst mobilefirst-adapters mobilefirst-studio


【解决方案1】:

从异步任务中取出创建和调用移动优先适配器的代码解决了我的问题。

在 android 中这样做会导致窗口泄漏。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    相关资源
    最近更新 更多