• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null Pointer Exception in Async Task

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi this is My AsyncTask code


this is showinng error on line
lv.setadapter this is my logcat

10-15 00:15:14.418: E/AndroidRuntime(1944): FATAL EXCEPTION: main
10-15 00:15:14.418: E/AndroidRuntime(1944): Process: com.addressbook, PID: 1944
10-15 00:15:14.418: E/AndroidRuntime(1944): java.lang.NullPointerException
10-15 00:15:14.418: E/AndroidRuntime(1944): at com.addressbook.View_Event$GetAllTask.onPostExecute(View_Event.java:140)
10-15 00:15:14.418: E/AndroidRuntime(1944): at com.addressbook.View_Event$GetAllTask.onPostExecute(View_Event.java:1)
10-15 00:15:14.418: E/AndroidRuntime(1944): at android.os.AsyncTask.finish(AsyncTask.java:632)
10-15 00:15:14.418: E/AndroidRuntime(1944): at android.os.AsyncTask.access$600(AsyncTask.java:177)
10-15 00:15:14.418: E/AndroidRuntime(1944): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
10-15 00:15:14.418: E/AndroidRuntime(1944): at android.os.Handler.dispatchMessage(Handler.java:102)
10-15 00:15:14.418: E/AndroidRuntime(1944): at android.os.Looper.loop(Looper.java:136)
10-15 00:15:14.418: E/AndroidRuntime(1944): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-15 00:15:14.418: E/AndroidRuntime(1944): at java.lang.reflect.Method.invokeNative(Native Method)
10-15 00:15:14.418: E/AndroidRuntime(1944): at java.lang.reflect.Method.invoke(Method.java:515)
10-15 00:15:14.418: E/AndroidRuntime(1944): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-15 00:15:14.418: E/AndroidRuntime(1944): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-15 00:15:14.418: E/AndroidRuntime(1944): at dalvik.system.NativeStart.main(Native Method)



I am getting value in doinBackground() checked using debug and it is showing error in adapter.

If I am not using AsyncTask my custom adapter is displaying and setting value in Adapter.

TaskData is a Simple POJO class.


Where I am wrong?


Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "lv" null?
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ulf

Lv was null I just find that by debug

Now its working fine
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first step in debugging a NPE should always be to determine which object is null. Once you now that, it's often clear where to look next.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NPE?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NullPointerException
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic