java - Fragment Webpage is not currently in the FragmentManager -
i have application contains viewpager loads 3 webpages local html file, works fine when try start intent in different activity crashes following message:
05-15 11:33:12.533 7702-7702/com.example.android.horizontalpaging e/fragmentmanager﹕ fragment webpage{22947acd} not in fragmentmanager 05-15 11:33:12.533 7702-7702/com.example.android.horizontalpaging e/fragmentmanager﹕ activity state: 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ active fragments in 3e30ef82: 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ #0: null 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ #1: null 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ #2: null 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ added fragments: 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ #0: webpage{22947acd} 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ #1: webpage{245bc693} 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ #2: webpage{1a4686d0} 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ fragmentmanager misc state: 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ mactivity=null 05-15 11:33:12.534 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ mcontainer=null 05-15 11:33:12.535 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ mcurstate=0 mstatesaved=true mdestroyed=true 05-15 11:33:12.535 7702-7702/com.example.android.horizontalpaging d/fragmentmanager﹕ mavailindices: [0, 1, 2] 05-15 11:33:12.535 7702-7702/com.example.android.horizontalpaging d/androidruntime﹕ shutting down vm 05-15 10:52:38.309 2589-2589/com.example.android.horizontalpaging e/androidruntime﹕ fatal exception: main process: com.example.android.horizontalpaging, pid: 2589 java.lang.illegalstateexception: fragment webpage{3e30ef82} not in fragmentmanager @ android.support.v4.app.fragmentmanagerimpl.putfragment(fragmentmanager.java:571) @ android.support.v4.app.fragmentstatepageradapter.savestate(fragmentstatepageradapter.java:188) @ android.support.v4.view.viewpager.onsaveinstancestate(viewpager.java:1270) @ android.view.view.dispatchsaveinstancestate(view.java:13669) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2859) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.viewgroup.dispatchsaveinstancestate(viewgroup.java:2865) @ android.view.view.savehierarchystate(view.java:13652) @ com.android.internal.policy.impl.phonewindow.savehierarchystate(phonewindow.java:1967) @ android.app.activity.onsaveinstancestate(activity.java:1366) @ android.app.activitygroup.onsaveinstancestate(activitygroup.java:66) @ android.app.tabactivity.onsaveinstancestate(tabactivity.java:112) @ android.app.activity.performsaveinstancestate(activity.java:1298) @ android.app.instrumentation.callactivityonsaveinstancestate(instrumentation.java:1288) @ android.app.activitythread.callcallactivityonsaveinstancestate(activitythread.java:3958) @ android.app.activitythread.performstopactivityinner(activitythread.java:3369) @ android.app.activitythread.handlestopactivity(activitythread.java:3425) @ android.app.activitythread.access$1100(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1332) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5254) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:903) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:698)
here's activity contains viewpager :
public class azkar extends actionbaractivity { public static sectionspageradapter msectionspageradapter; public static viewpager mviewpager; string[] tabstitle = {"أذكار الصباح","أذكار المساء","أذكار الصلاة"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.azkar); msectionspageradapter = new sectionspageradapter(getsupportfragmentmanager()); mviewpager = (viewpager) findviewbyid(r.id.pager); mviewpager.setoffscreenpagelimit(3-1); mviewpager.setadapter(msectionspageradapter); pagerslidingtabstrip tabs = (pagerslidingtabstrip) findviewbyid(r.id.tabs); tabs.settextsize(40); tabs.setviewpager(mviewpager); } public class sectionspageradapter extends fragmentstatepageradapter{ public sectionspageradapter(fragmentmanager fm) { super(fm); } @override public fragment getitem(int position) { fragment fragment = null; bundle args = new bundle(); switch (position){ case 0: fragment = new webpage(); args.putint(webpage.arg_section_number, position); fragment.setarguments(args); break; case 1: fragment = new webpage(); args.putint(webpage.arg_section_number, position); fragment.setarguments(args); break; default: fragment = new webpage(); args.putint(webpage.arg_section_number, position); fragment.setarguments(args); break; } return fragment; } public int getitemposition(object object) { if(object==null) return position_unchanged; return position_none; } @override public charsequence getpagetitle(int position) { return tabstitle[position]; } @override public int getcount() { return 3; } } }
and this's webpage fragment:
public class webpage extends fragment { public static final string arg_section_number = "section_number"; private webview webview; public webpage() { } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.webpage, container, false); textview pagenumber = (textview) rootview.findviewbyid(r.id.pagenumber); pagenumber.settext(integer.tostring(getarguments().getint(arg_section_number))); webview = (webview) rootview.findviewbyid(r.id.webview); int number = getarguments().getint(arg_section_number); string file = null; switch (number){ case 0: file = "morning.html"; break; case 1: file = "evning.html"; break; case 2: file = "prayer.html"; break; default: break; } webview.loadurl("file:///android_asset/"+file); return rootview; } @override public void onlowmemory() { super.onlowmemory(); } }
hope figure out fix this. in advance
Comments
Post a Comment