Android fragment commit illegal state exception only when phone is locked -
Android fragment commit illegal state exception only when phone is locked -
i committing fragment on receiving broadcast, such as
broadcastreceiver br = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { // log.e(tag,"inside onreceive"); if (intent.getaction().equalsignorecase( data_available)) initfragments.run(); } }
initfragment runnable code
databrowse = new songlistfragment(); getsupportfragmentmanager().begintransaction() ./*replace*/ add together (r.id.container, databrowse ).commit();
it works time perfect, , except when phone locked. why happens? solution of cause?
the log :
06-23 03:56:38.210: e/androidruntime(11174): fatal exception: main 06-23 03:56:38.210: e/androidruntime(11174): java.lang.runtimeexception: error receiving broadcast intent { act=dat_avail flg=0x10 } in com.example.mainactivity$1@41b98e90 06-23 03:56:38.210: e/androidruntime(11174): @ android.app.loadedapk$receiverdispatcher$args.run(loadedapk.java:765) 06-23 03:56:38.210: e/androidruntime(11174): @ android.os.handler.handlecallback(handler.java:615) 06-23 03:56:38.210: e/androidruntime(11174): @ android.os.handler.dispatchmessage(handler.java:92) 06-23 03:56:38.210: e/androidruntime(11174): @ android.os.looper.loop(looper.java:137) 06-23 03:56:38.210: e/androidruntime(11174): @ android.app.activitythread.main(activitythread.java:4898) 06-23 03:56:38.210: e/androidruntime(11174): @ java.lang.reflect.method.invokenative(native method) 06-23 03:56:38.210: e/androidruntime(11174): @ java.lang.reflect.method.invoke(method.java:511) 06-23 03:56:38.210: e/androidruntime(11174): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1006) 06-23 03:56:38.210: e/androidruntime(11174): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:773) 06-23 03:56:38.210: e/androidruntime(11174): @ dalvik.system.nativestart.main(native method) 06-23 03:56:38.210: e/androidruntime(11174): caused by: java.lang.illegalstateexception: can not perform action after onsaveinstancestate 06-23 03:56:38.210: e/androidruntime(11174): @ android.support.v4.app.fragmentmanagerimpl.checkstateloss(fragmentmanager.java:1343) 06-23 03:56:38.210: e/androidruntime(11174): @ android.support.v4.app.fragmentmanagerimpl.enqueueaction(fragmentmanager.java:1361) 06-23 03:56:38.210: e/androidruntime(11174): @ android.support.v4.app.backstackrecord.commitinternal(backstackrecord.java:595) 06-23 03:56:38.210: e/androidruntime(11174): @ android.support.v4.app.backstackrecord.commit(backstackrecord.java:574) 06-23 03:56:38.210: e/androidruntime(11174): @ com.example.mainactivity$3.run(mainactivity.java:228) 06-23 03:56:38.210: e/androidruntime(11174): @ com.example.mainactivity$1.onreceive(mainactivity.java:101) 06-23 03:56:38.210: e/androidruntime(11174): @ android.app.loadedapk$receiverdispatcher$args.run(loadedapk.java:755) 06-23 03:56:38.210: e/androidruntime(11174): ... 9 more 06-23 03:56:38.245: i/process(11174): sending signal. pid: 11174 sig: 9
i think there state loss occurring in program, 1 of solution save instance , restore intstance avoid state loss , commit allowing state loss can have @ blogspot fragment transactions & activity state loss
android android-fragments illegalstateexception android-actionbaractivity
Comments
Post a Comment