android - String null pointer exception -


i have strange nullpointerexception @ app.

i run code:

protected void onpostexecute(void result) {                     log.i("name1", userprofilepictures[positionforpicture][0]);      if(movedtoanotheractivity)         return;      if(loadnewposts && loaded10more == false)     {                    firstlooppicture = true;         positionforpicture = 0;         return;      }      if((positionforpicture  == userprofilepictures.length) == false)     {         new getuserpicture().execute();          int loadlength = loadedpostssaverforpictures.length;          string name = userprofilepictures[positionforpicture][0];          log.i("name", name);     } } 

... ... ...

and null pointer exception @ line:

string name = userprofilepictures[positionforpicture][0];     log.i("name", name); 

log cat:

08-28 17:39:28.140: e/androidruntime(26801): fatal exception: main 08-28 17:39:28.140: e/androidruntime(26801): java.lang.nullpointerexception: println needs message 08-28 17:39:28.140: e/androidruntime(26801):    @ android.util.log.println_native(native method) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.util.log.i(log.java:159) 08-28 17:39:28.140: e/androidruntime(26801):    @ com.example.workoutlog.workoutswall$getuserpicture.onpostexecute(workoutswall.java:3420) 08-28 17:39:28.140: e/androidruntime(26801):    @ com.example.workoutlog.workoutswall$getuserpicture.onpostexecute(workoutswall.java:1) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.os.asynctask.finish(asynctask.java:631) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.os.asynctask.access$600(asynctask.java:177) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:644) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.os.handler.dispatchmessage(handler.java:99) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.os.looper.loop(looper.java:137) 08-28 17:39:28.140: e/androidruntime(26801):    @ android.app.activitythread.main(activitythread.java:5226) 08-28 17:39:28.140: e/androidruntime(26801):    @ java.lang.reflect.method.invokenative(native method) 08-28 17:39:28.140: e/androidruntime(26801):    @ java.lang.reflect.method.invoke(method.java:511) 08-28 17:39:28.140: e/androidruntime(26801):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:795) 08-28 17:39:28.140: e/androidruntime(26801):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:562) 08-28 17:39:28.140: e/androidruntime(26801):    @ dalvik.system.nativestart.main(native method) 

the strange thing before lines have code:

log.i("name1", userprofilepictures[positionforpicture][0]); 

which giving me string , not null error.

why null pointer exception? same string...

if async task loading array userprofilepictures should wait answer. return boolean in postexecute , do:

boolean b= new getuserpicture().execute(); 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -