facebook - Android : FragmentManager is already executing transactions -
i trying implement logging facebook, when 1 authentifiate have error :
java.lang.illegalstateexception: fragmentmanager executing transactions @ android.support.v4.app.fragmentmanagerimpl.ensureexecready(fragmentmanager.java:1956) @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:2007) @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:763) @ android.support.v4.app.fragmenttabhost.onattachedtowindow(fragmenttabhost.java:289) @ android.view.view.dispatchattachedtowindow(view.java:14514) @ android.view.viewgroup.dispatchattachedtowindow(viewgroup.java:2836) @ android.view.viewgroup.addviewinner(viewgroup.java:4348) @ android.view.viewgroup.addview(viewgroup.java:4145) @ android.view.viewgroup.addview(viewgroup.java:4086) @ android.view.viewgroup.addview(viewgroup.java:4059) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1309) @ android.support.v4.app.fragmentmanagerimpl.movefragmenttoexpectedstate(fragmentmanager.java:1528) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1595) @ android.support.v4.app.backstackrecord.executeops(backstackrecord.java:758) @ android.support.v4.app.fragmentmanagerimpl.executeops(fragmentmanager.java:2363) @ android.support.v4.app.fragmentmanagerimpl.executeopstogether(fragmentmanager.java:2149) @ android.support.v4.app.fragmentmanagerimpl.optimizeandexecuteops(fragmentmanager.java:2103) @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:2013) @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:710) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)
my logging in fragment, try switch replace fragment in fragmentmanager :
fragment_login :
public class fragment_login extends fragment implements header{ private loginbutton loginbutton; private callbackmanager callbackmanager; private profiletracker profiletracker; private accesstokentracker accesstokentracker; private view view; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view = inflater.inflate(r.layout.fragment_login, container, false); callbackmanager= callbackmanager.factory.create(); accesstokentracker = new accesstokentracker() { @override protected void oncurrentaccesstokenchanged(accesstoken oldaccesstoken, accesstoken currentaccesstoken) { } }; profiletracker = new profiletracker() { @override protected void oncurrentprofilechanged(profile oldprofile, profile currentprofile) { loggingvalidate(currentprofile); } }; accesstokentracker.starttracking(); profiletracker.starttracking(); loginbutton = (loginbutton) view.findviewbyid(r.id.fb_login); loginbutton.setfragment(this); facebookcallback<loginresult> callback = new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { profile profile = profile.getcurrentprofile(); loggingvalidate(profile); } @override public void oncancel() { log.i("cancel",""); } @override public void onerror(facebookexception error) { log.i("cancel",error.tostring()); } }; loginbutton.setreadpermissions("user_friends"); loginbutton.registercallback(callbackmanager, callback); return view; } @override public void onresume() { super.onresume(); profile profile= profile.getcurrentprofile(); loggingvalidate(profile); } @override public void onpause() { super.onpause(); } @override public void onstop() { super.onstop(); accesstokentracker.stoptracking(); profiletracker.stoptracking(); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); callbackmanager.onactivityresult(requestcode, resultcode, data); } private void loggingvalidate (profile profile){ if(profile != null){ ((main) getactivity()).getsharedpreferences() .edit() .putstring(prefs_photo, profile.getprofilepictureuri(200,200).tostring()) .putstring(prefs_prenom, profile.getfirstname()) .putstring(prefs_nom, profile.getlastname()) .apply(); getfragmentmanager() .begintransaction() .replace(r.id.fragment_container, new fragment_main(), "mainfragment") .addtobackstack("mainfragment") .commit(); } }
i not understand code error. please can explain me have made badly ?
thanks
Comments
Post a Comment