java - Get bundle values in Android -


i'm still confused why i'm having error getting values bundle of main activity.

so, here's code snippet:

level1.class

chronometer chrono; chrono = (chronometer)findviewbyid(r.id.chronometer1); chrono.start();  long timeelapsed = systemclock.elapsedrealtime() - chrono.getbase(); int hours = (int) (timeelapsed / 3600000); int minutes = (int) (timeelapsed - hours * 3600000) / 60000; int seconds = (int) (timeelapsed - hours * 3600000 - minutes * 60000) / 1000;  intent lvl1 = new intent(getapplicationcontext(), finish.class);     bundle time1 = new bundle(); time1.putint("hour1", hours); time1.putint("minutes1", minutes); time1.putint("seconds1", seconds);  lvl1.putextras(time1); 

and finish.class: (inside oncreate method)

textview set1;  set1 = (textview) findviewbyid (r.id.time1);  bundle time1 = getintent().getextras(); int hrs = time1.getint("hour1"); int min = time1.getint("minutes1");  int sec = time1.getint("seconds1");   set1.settext(hrs + ":" + min + ":" + sec); 

could tell me why i'm having errors?

note: error in line 30, int hrs = time1.getint("hour1");.

logcat:

08-20 01:54:10.461: e/androidruntime(950): fatal exception: main 08-20 01:54:10.461: e/androidruntime(950): java.lang.runtimeexception: unable start activity componentinfo{com.example.mathattack/com.example.mathattack.finish}: java.lang.nullpointerexception 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.activitythread.performlaunchactivity(activitythread.java:2663) 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.activitythread.handlelaunchactivity(activitythread.java:2679) 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.activitythread.access$2300(activitythread.java:125) 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.activitythread$h.handlemessage(activitythread.java:2033) 08-20 01:54:10.461: e/androidruntime(950):  @ android.os.handler.dispatchmessage(handler.java:99) 08-20 01:54:10.461: e/androidruntime(950):  @ android.os.looper.loop(looper.java:123) 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.activitythread.main(activitythread.java:4627) 08-20 01:54:10.461: e/androidruntime(950):  @ java.lang.reflect.method.invokenative(native method) 08-20 01:54:10.461: e/androidruntime(950):  @ java.lang.reflect.method.invoke(method.java:521) 08-20 01:54:10.461: e/androidruntime(950):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 08-20 01:54:10.461: e/androidruntime(950):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 08-20 01:54:10.461: e/androidruntime(950):  @ dalvik.system.nativestart.main(native method) 08-20 01:54:10.461: e/androidruntime(950): caused by: java.lang.nullpointerexception 08-20 01:54:10.461: e/androidruntime(950):  @ com.example.mathattack.finish.oncreate(finish.java:30) 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 08-20 01:54:10.461: e/androidruntime(950):  @ android.app.activitythread.performlaunchactivity(activitythread.java:2627) 08-20 01:54:10.461: e/androidruntime(950):  ... 11 more 

you need debug code , put break points bundle intent check value in bundle. without doing guess ours.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -