-2

This is the output I am getting from my server script:

{"task_id":"1","task_create_time":"2015-08-09 22:48:25","task_end_time":"0000-00-00 ``00:00:00","service_id":"2","task_status":"1","user_id":"1","user_email":"[email protected]","user_name":"rr","user_mobile":"1234567890"}{"task_id":"3","task_create_time":"2015-08-13 00:23:54","task_end_time":"0000-00-00 00:00:00","service_id":"2","task_status":"1","user_id":"2","user_email":null,"user_name":null,"user_mobile":null}

I want to convert this output to a custom list in Android, but I am getting many errors. My code:

try {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url_jobdetail);
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity();
    is = entity.getContent();

    // Toast.makeText(getApplicationContext(), “pass”,
    // Toast.LENGTH_SHORT).show();
} catch (Exception e) {

}
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
    sb.append(line + "\n");         
}
is.close();

result = sb.toString();

this the error i am getting

08-13 12:42:34.935: I/InputMethodManager(23564): handleMessage: MSG_SET_ACTIVE true, was false

08-13 12:42:39.463: D/AbsListView(23564): checkAbsListViewlLogProperty get invalid command 08-13 12:42:39.478: D/AndroidRuntime(23564): Shutting down VM 08-13 12:42:39.478: W/dalvikvm(23564): threadid=1: thread exiting with uncaught exception (group=0x40cb49c0) 08-13 12:42:39.499: E/AndroidRuntime(23564): FATAL EXCEPTION: main 08-13 12:42:39.499: E/AndroidRuntime(23564): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.OnDeOS.ondeos_internal/com.OnDeOS.ondeos_internal.jobs}: java.lang.NullPointerException 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.ActivityThread.access$600(ActivityThread.java:162) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.os.Handler.dispatchMessage(Handler.java:107) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.os.Looper.loop(Looper.java:194) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.ActivityThread.main(ActivityThread.java:5371) 08-13 12:42:39.499: E/AndroidRuntime(23564): at java.lang.reflect.Method.invokeNative(Native Method) 08-13 12:42:39.499: E/AndroidRuntime(23564): at java.lang.reflect.Method.invoke(Method.java:525) 08-13 12:42:39.499: E/AndroidRuntime(23564): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 08-13 12:42:39.499: E/AndroidRuntime(23564): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 08-13 12:42:39.499: E/AndroidRuntime(23564): at dalvik.system.NativeStart.main(Native Method) 08-13 12:42:39.499: E/AndroidRuntime(23564): Caused by: java.lang.NullPointerException 08-13 12:42:39.499: E/AndroidRuntime(23564): at com.OnDeOS.ondeos_internal.jobs.onCreate(jobs.java:67) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.Activity.performCreate(Activity.java:5122) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 08-13 12:42:39.499: E/AndroidRuntime(23564): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 08-13 12:42:39.499: E/AndroidRuntime(23564): ... 11 more

2
  • possible duplicate of filter json array php by string Commented Aug 12, 2015 at 19:07
  • I recommend to try to use Gson to se/deserialize your JSON, or Jackson make it too, are easy to understand. And the other is to use Volley from Google or Retrofit by Square to make your requests, arent hard to implement and lets you handle pretty/faster/extensible way this kind of things. Regards Commented Aug 13, 2015 at 2:34

1 Answer 1

-1

Are you able to get the response in your "result" variable? If so, you can parse it like so:

JSONObject responseObject = new JSONObject(result);
Sign up to request clarification or add additional context in comments.

2 Comments

i am not getting any value from the following code. the code follow get stop at this point BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
@AlagarRaja Post the Logcat to your question. If you have erros, we need details about them to be able to help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.