Skip to content Skip to sidebar Skip to footer

Android : Getting RuntimeException On AsyncTask

In the code I try to read from a web service with an http client. Then I want to write the Responce Phrase of the http responce to a text view. The UI is accessed through onPostEx

Solution 1:

Caused by: java.lang.NullPointerException
09-28 09:43:34.239: E/AndroidRuntime(679):  at com.test.CustomersScreen$Get_data.doInBackground(CustomersScreen.java:46)

You have a NPE in line 46 of your class. The code, posted lacks some lines obviously, but I suppose it's this line String phrase = response.getStatusLine().getReasonPhrase(); as response would be null if anything goes wrong with the httpclient.execute(request);

So, just put that line within the try/catch block as well and add a simple return null; at the end of the method instead.


Post a Comment for "Android : Getting RuntimeException On AsyncTask"