android - Error having 2 fragments with SupportMapFragment -
so, have activity holds tabs, each tab has fragment assigned it, can navigate through fragments using tabs. in 2 of these tabs have load map (with different information on each of them, different pins, etc) problem loads first one, i'm using code assigning each tab fragment desired (this adapter working fine).
@override public fragment getitem(int pos) { switch (pos) { case 0: return new searchfragment(); case 1: return new parkfragment(); case 2: setactivesessionsfragment(); return mactivesessionsfragment; case 3: return new choosepaymentmethodfragment(); default: return new parkfragment(); } }
being case 0 , 2 ones loading map, if substitute of these other fragment 1 map works fine, if leave both app crashes. in both fragments i'm loading map in framelayout one:
<framelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/map_container_search_tab" android:background="@color/gray"></framelayout>
and create them programmatically by:
@override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); //create new map fragment supportmapfragment mapfragment = supportmapfragment.newinstance(); getfragmentmanager().begintransaction().add(r.id.map_container_search_tab, mapfragment).commit(); mapfragment.getmapasync(this); }
however have no ondestroy method nor ondestroyview, i've tried implement these i've seen in other responses it's not working , have tried solve myself whole week now. method tried no luck
public void ondestroyview() { super.ondestroyview(); if (mmap != null) { getfragmentmanager().begintransaction() .remove(getfragmentmanager().findfragmentbyid(r.id.map_container)) .commit(); }
this logcat when crashes:
05-16 15:09:33.540 24971-24971/? e/androidruntime: fatal exception: main process: com.parso.mobile.android, pid: 24971 java.lang.illegalstateexception: can not perform action after onsaveinstancestate @ android.support.v4.app.fragmentmanagerimpl.checkstateloss(fragmentmanager.java:1489) @ android.support.v4.app.fragmentmanagerimpl.enqueueaction(fragmentmanager.java:1507) @ android.support.v4.app.backstackrecord.commitinternal(backstackrecord.java:634) @ android.support.v4.app.backstackrecord.commit(backstackrecord.java:613) @ com.parso.mobile.android.fragments.searchfragment.onactivitycreated(searchfragment.java:108) @ android.support.v4.app.fragment.performactivitycreated(fragment.java:1970) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1092) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1248) @ android.support.v4.app.backstackrecord.run(backstackrecord.java:738) @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1613) @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:570) @ android.support.v4.app.fragmentstatepageradapter.finishupdate(fragmentstatepageradapter.java:163) @ android.support.v4.view.viewpager.populate(viewpager.java:1106) @ android.support.v4.view.viewpager.setcurrentiteminternal(viewpager.java:552) @ android.support.v4.view.viewpager.setcurrentiteminternal(viewpager.java:514) @ android.support.v4.view.viewpager.datasetchanged(viewpager.java:946) @ android.support.v4.view.viewpager$pagerobserver.onchanged(viewpager.java:2910) @ android.database.datasetobservable.notifychanged(datasetobservable.java:37) @ android.support.v4.view.pageradapter.notifydatasetchanged(pageradapter.java:276) @ com.parso.mobile.android.mainactivity.onparkingsessioncreated(mainactivity.java:240) @ com.parso.mobile.android.fragments.confirmsessionfragment$createparkingsessiontask.onpostexecute(confirmsessionfragment.java:213) @ com.parso.mobile.android.fragments.confirmsessionfragment$createparkingsessiontask.onpostexecute(confirmsessionfragment.java:189) @ android.os.asynctask.finish(asynctask.java:632) @ android.os.asynctask.access$600(asynctask.java:177) @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:645) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5538) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:958) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:753)
Comments
Post a Comment