android asynctask illegalargumentexception

时间:2014-12-08 12:59:20

标签: android android-asynctask xmlhttprequest http-get illegalstateexception

我有一个asynctask class.i尝试发送http request.i还写了另一个asynctask类,我发送了一些字符串与http请求(GET),现在我想发送json string.i反序列化json,我想发送我的儿子。但我有非法的感觉 p.s我成功反序列化,我可以在Log中显示我的json。但我不知道我的异步任务类有什么问题

public void SendFacebookIdToServer1(final String my_json) {
    class HttpGetAsyncTask2 extends AsyncTask<String, Void, String> {

        ProgressDialog pDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            pDialog = new ProgressDialog(getActivity());

            pDialog.setCancelable(false);
            pDialog.show();
            pDialog.setContentView(R.layout.custom_progressdialog);

        }

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

            try {

                HttpClient httpClient = new DefaultHttpClient();
                SendUrl = SendUrl + my_json;
                HttpGet httpGet = new HttpGet(SendUrl.trim());

                HttpResponse httpResponse = httpClient.execute(httpGet);
                System.out.println("httpResponse");
                InputStream inputStream = httpResponse.getEntity()
                        .getContent();
                InputStreamReader inputStreamReader = new InputStreamReader(
                        inputStream);
                BufferedReader bufferedReader = new BufferedReader(
                        inputStreamReader);
                StringBuilder stringBuilder = new StringBuilder();

                String bufferedStrChunk = null;
                while ((bufferedStrChunk = bufferedReader.readLine()) != null) {
                    stringBuilder.append(bufferedStrChunk);
                    System.out.println(SendUrl);
                }
                System.out.println("Returning value of doInBackground :"
                        + stringBuilder.toString());
                return stringBuilder.toString();

            } catch (ClientProtocolException cpe) {
                System.out
                        .println("Exception generates caz of httpResponse :"
                                + cpe);
                cpe.printStackTrace();
            } catch (IOException ioe) {
                System.out
                        .println("Second exception generates caz of httpResponse :"
                                + ioe);
                ioe.printStackTrace();
            }
            return null;
        }

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

            Log.e("result isssssssss", result);

            if (pDialog != null) {
                pDialog.dismiss();

                pDialog = null;
            }



        }
    }

    HttpGetAsyncTask2 httpGetAsyncTask2 = new HttpGetAsyncTask2();

    httpGetAsyncTask2.execute();
}
我正在调用我的函数

SendFacebookIdToServer1(jsonDeserialize);

enter image description here

如果有人知道解决方案,请帮助我 感谢

0 个答案:

没有答案