asynchtask突然停止工作android

时间:2015-05-22 18:57:10

标签: android android-asynctask

在我的Android应用程序中,我使用webservice,所以我经常使用GET,POST和PUT。我有一种更新用户帐户的方法。它完美地工作了一个星期直到今天,我试图使用它数据还没有更新。我调试了代码一切正常。我不知道问题在哪里。为什么它已停止工作。这是我称之为new registerIdreg().execute(regId);

的课程
   private class registerIdreg extends AsyncTask<String, Integer, Double> {

    @Override
    protected Double doInBackground(String... params) {
        // TODO Auto-generated method stub
        postData(params[0]);
        return null;
    }



    public void postData(String valueIWantToSend) {
        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();


        HttpPut httppost = new HttpPut("http://myserver/api/users/active_push/id/"+id_user);

        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("regId",valueIWantToSend));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
    }

}

0 个答案:

没有答案