java - Android -Stuck with Bundles -


i have 3 activities in android application.activity ,activity b,activity c..

in activity ,i'm doing json parsing , send values activity b using bundles , handle in many ways .

here code used in activity b values.

        intent in = getintent();     bundle b = in.getextras();       /*/----------future use ---------------------     string id1 = b.getstring("id");     string mc1 = b.getstring("machine_code");      ------------------------------------------/*/       string di1 = b.getstring("di1");     string di2 = b.getstring("di2");     string di3 = b.getstring("di3");     string di4 = b.getstring("di4");     string di5 = b.getstring("di5");     string di6 = b.getstring("di6");     string di7 = b.getstring("di7");     string di8 = b.getstring("di8"); 

in activity b .i've button move activity c , in activity c ,i've button move activity b again .

my problem when when go activity c b.my app force closes .

my logcat error given below.

03-25 11:22:31.699: e/androidruntime(307): uncaught handler: thread main exiting due uncaught exception 03-25 11:22:31.719: e/androidruntime(307): java.lang.runtimeexception: unable start activity componentinfo{com.example.gprs/com.example.gprs.mainactivity}: java.lang.nullpointerexception 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.activitythread.performlaunchactivity(activitythread.java:2496) 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.activitythread.handlelaunchactivity(activitythread.java:2512) 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.activitythread.access$2200(activitythread.java:119) 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.activitythread$h.handlemessage(activitythread.java:1863) 03-25 11:22:31.719: e/androidruntime(307):  @ android.os.handler.dispatchmessage(handler.java:99) 03-25 11:22:31.719: e/androidruntime(307):  @ android.os.looper.loop(looper.java:123) 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.activitythread.main(activitythread.java:4363) 03-25 11:22:31.719: e/androidruntime(307):  @ java.lang.reflect.method.invokenative(native method) 03-25 11:22:31.719: e/androidruntime(307):  @ java.lang.reflect.method.invoke(method.java:521) 03-25 11:22:31.719: e/androidruntime(307):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) 03-25 11:22:31.719: e/androidruntime(307):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) 03-25 11:22:31.719: e/androidruntime(307):  @ dalvik.system.nativestart.main(native method) 03-25 11:22:31.719: e/androidruntime(307): caused by: java.lang.nullpointerexception 03-25 11:22:31.719: e/androidruntime(307):  @ com.example.gprs.mainactivity.oncreate(mainactivity.java:175) 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 03-25 11:22:31.719: e/androidruntime(307):  @ android.app.activitythread.performlaunchactivity(activitythread.java:2459) 03-25 11:22:31.719: e/androidruntime(307):  ... 11 more 03-25 11:22:31.760: i/dalvikvm(307): threadid=7: reacting signal 3 03-25 11:22:31.760: e/dalvikvm(307): unable open stack trace file '/data/anr/traces.txt': permission denied 03-25 11:22:37.569: i/process(307): sending signal. pid: 307 sig: 9 

in logcat can see mainactivity(which activity b)

this because bundle b = in.getextras(); returns null when come activity b activity c.

first case, sending bundle activity a activity b, when coming activity c, don't think you're sending bundle in intent. , hence, when try string di1 = b.getstring("di1"); null(bundle b), you'll nullpointerexception.

have null check before trying access bundle in activity b.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -