Mobile First Native Android - 适配器不返回任何结果

时间:2015-04-15 18:05:17

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

我正在关注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停止工作。"

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

下面是我的Android原生代码。

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

         }
    }

1 个答案:

答案 0 :(得分:0)

从异步任务中取出创建并调用移动第一个适配器的代码解决了我的问题。

android中有一个窗口泄漏。