Using Bundle in an activity in Android -


i have intermittent issue in using bundle. have created widget , when user clicks widget widget opens mainscreen , bundle value there. part working fine without issue.

the problem when open mainactivity screen directly (by clicking icon in homescreen) getting nullpointerexception in place have declared bundle. once error not able open app unless force stop or clear data.

the same code working fine on samsung s3 running 4.3, nexus one, galaxy nexus too. getting issue in kitkat 4.4.4..

i not sure why going inside bundle when haven't put in bundle. here have done in mainactivity

 bundle bundle =  getintent().getextras();  if(bundle != null)    { string callfromwidget = bundle.getstring("callfromwidget"); log.e("!null","why coming inside bundle " +callfromwidget);  if(callfromwidget.equalsignorecase(res.getstring(r.string.widget))) {       //do     }  }  else  {       //update database there nothing bundle   } 

here logs:

06-27 15:55:26.824: e/!null(7251): why coming inside bundle null 06-27 15:55:26.824: d/androidruntime(7251): shutting down vm 06-27 15:55:26.824: e/androidruntime(7251): fatal exception: main 06-27 15:55:26.824: e/androidruntime(7251): process: com.vkv.projectb, pid: 7251 06-27 15:55:26.824: e/androidruntime(7251): java.lang.runtimeexception: unable start activity componentinfo{com.vkv.projectb/com.vkv.projectb.main}: java.lang.nullpointerexception: attempt invoke virtual method 'boolean java.lang.string.equalsignorecase(java.lang.string)' on null object reference 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2184) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2233) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activitythread.access$800(activitythread.java:135)  06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.os.handler.dispatchmessage(handler.java:102) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.os.looper.loop(looper.java:136) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activitythread.main(activitythread.java:5001) 06-27 15:55:26.824: e/androidruntime(7251):     @ java.lang.reflect.method.invoke(native method) 06-27 15:55:26.824: e/androidruntime(7251):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 06-27 15:55:26.824: e/androidruntime(7251):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 06-27 15:55:26.824: e/androidruntime(7251): caused by: java.lang.nullpointerexception: attempt invoke virtual method 'boolean java.lang.string.equalsignorecase(java.lang.string)' on null object reference 06-27 15:55:26.824: e/androidruntime(7251):     @ com.vkv.projectb.main.oncreate(main.java:218) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activity.performcreate(activity.java:5231) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) 06-27 15:55:26.824: e/androidruntime(7251):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2148) 06-27 15:55:26.824: e/androidruntime(7251):     ... 9 more 

if(!textutils.isempty(callfromwidget)) {     //    apply code }  

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -