0

此代码有时有效,但不幸的是停止工作。我没有在后台更改任何东西(UI)。

给出以下错误。

01-28 06:42:53.060: E/AndroidRuntime(4993): FATAL EXCEPTION: AsyncTask #1
01-28 06:42:53.060: E/AndroidRuntime(4993): java.lang.RuntimeException: An error occured while executing doInBackground()
01-28 06:42:53.060: E/AndroidRuntime(4993):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
01-28 06:42:53.060: E/AndroidRuntime(4993):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
01-28 06:42:53.060: E/AndroidRuntime(4993):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
01-28 06:42:53.060: E/AndroidRuntime(4993):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
01-28 06:42:53.060: E/AndroidRuntime(4993):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
01-28 06:42:53.060: E/AndroidRuntime(4993):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)

    And also could you please explain how to get Respose when i am recieving Respose as Event from TIBCO BE. it is replying with event with properties (Status). 

IN onCreateBudle new MyTask().execute(u); startActivity(new Intent(AddUserActivity.this,InputActivity.class));

                ProgressDialog dialog;       
                @Override
                protected void onPreExecute() {
                    // TODO Auto-generated method stub
                    super.onPreExecute();
                    dialog = ProgressDialog.show(AddUserActivity.this, "",
                            "User is Registering...");

                }
                @Override
                protected String doInBackground(String... uri) {
            String responseString = null;

                    HttpClient httpclient = new DefaultHttpClient();
                    HttpResponse response;
                    HttpParams params;

                    try {
                        response = httpclient.execute(new HttpGet(uri[0]));
                        StatusLine statusLine = response.getStatusLine();

                        if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
                            ByteArrayOutputStream out = new ByteArrayOutputStream();
                            response.getEntity().writeTo(out);

                            responseString = response.getEntity().getContent().toString();

                            /*params = response.getParams();

                            responseString = (String) params.getParameter("Status");*/
                            out.close();

                        } else {
                            // Closes the connection.
                            response.getEntity().getContent().close();
                            throw new IOException(statusLine.getReasonPhrase());
                        }
                    } catch (ClientProtocolException e) {
                        // TODO Handle problems..
                    } catch (IOException e) {
                        // TODO Handle problems..
                    }

                    return responseString;
                }

                @Override
                protected void onPostExecute(String result) {
                    super.onPostExecute(result);

                    Log.e("OnPostExecute",result);

                    dialog.dismiss();

                    Toast.makeText(AddUserActivity.this, "User Registerd", Toast.LENGTH_LONG).show();}  }
4

1 回答 1

0
     @Override
    protected void onPostExecute(String result) {
    // super.onPostExecute(result);

       Log.e("OnPostExecute",result);
       try {
                dialog.dismiss();
                dialog = null;
            } catch (Exception e) {
                e.getMessage();
            }


    }

试试这个跳它对你有帮助。

于 2013-01-28T06:53:59.160 回答