HttpPost: InputDispatcher: "Kanal ist unrecoverably fehlgeschlagen kaputt und wird entsorgt!" auf dem Nexus 7

Auf dem Nexus 7 (4.3), und nicht auf mein älteres Gerät, den LG Optimus 3d (Android 2.2),
wenn ich HttpPost, bekomme ich diese

E/InputDispatcher﹕ Kanal '4273f7b0 ... MainActivity (server)' ~ Kanal ist unrecoverably fehlgeschlagen gebrochen und entsorgt werden!

Leute haben erwähnt, eine mögliche memory leak. Sehen **. Jedoch dieses problem tritt sofort beim Start, wenn ich versuche die HttpPost. Ist es wahrscheinlich immer noch ein memory-leak?

Hier ist, wie mache ich das HttpPost:

public void server_addUserGetId()
{
    String url = GS.baseUrl() + "/users";
    HttpPost theHttpPost = new HttpPost(url);

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("dId", s_UserInfo.getInstance().m_device_id ));
    try {
        theHttpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    HttpPostAsync theHttpPostAsync = new HttpPostAsync(new OnPostExecuteHandler() {
        @Override
        public void handlePostExecute(Object oHttpResponse) {
            HttpResponse theHttpResponse = (HttpResponse) oHttpResponse;
            JSONObject jo = GS.getJSONObject(theHttpResponse.getEntity());
            try {
                s_UserInfo.getInstance().m_user_id = jo.getString("_id");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
    theHttpPostAsync.execute(theHttpPost);
    return;
}

Hier ist mein HttpPostAsync Aufgabe:

public class HttpPostAsync extends AsyncTask<HttpPost, Integer, HttpResponse>
{
    private HttpPost m_HttpPost;
    private HttpResponse m_HttpResponse;

    private OnPostExecuteHandler m_OnPostExecuteHandler;
    public HttpPostAsync(OnPostExecuteHandler listener)
    {
        m_OnPostExecuteHandler = listener;
    }

    protected HttpResponse doInBackground(HttpPost ... args)
    {
        m_HttpPost = args[0];
        if(GS.dl>5) Log.d("GRA: HttpPostAsync", "doInBackground: Thread.currentThread().getId()=" + Thread.currentThread().getId());
        m_HttpResponse = visit(m_HttpPost);
        return m_HttpResponse;
    }

    protected void onProgressUpdate(Integer... progress) {
    }

    protected void onPostExecute(Long result) {
        if(GS.dl>5) Log.d("GRA: HttpPostAsync", "onPostExecute: Thread.currentThread().getId()=" + Thread.currentThread().getId());
        if(GS.dl>5) Log.d("GRA: HttpPostAsync", "onPostExecute: result=" + result);
        //if(GS.dl>5) Log.d("GRA: HttpPostAsync", "onPostExecute: m_HttpEntity="+m_HttpEntity);
        m_OnPostExecuteHandler.handlePostExecute(m_HttpResponse);
    }

    public HttpResponse visit(HttpPost theHttpPost)
    {
        HttpResponse response = null;
        try {
            //Create a new HttpClient and Post Header
            HttpClient httpclient = new DefaultHttpClient();
            //Execute HTTP Post Request
            response = httpclient.execute(theHttpPost);
        } catch (IOException e) {
            e.printStackTrace();
            Log.d("HttpPostAsync.java", "IOException e=" + e);
            //TODO Auto-generated catch block
        }
        return response;
    }
}

Irgendwelche Ideen?

Las ich auf einer SO beantworten* es könnte zu tun haben mit der ArrayList Initialisierung, also habe ich auch versucht zu initialisieren, wie diese, mit 1, in der ArrayList, aber das problem besteht weiterhin:

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);

*: ALSO Antworten, die nicht völlig beziehen/Hilfe:
App funktioniert nicht mehr Android

** memory-leak zu tun? http://android-developers.blogspot.com/2011/03/memory-analysis-for-android.html

InformationsquelleAutor mylord | 2014-03-31

Schreibe einen Kommentar