0

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

当我右键单击适配器时适配器工作正常 --> 运行方式 --> 调用 Mobile First Adapter

下面是我的 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) {

         }
    }
4

1 回答 1

0

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

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

于 2015-04-16T02:02:25.180 回答