我正在开发一个带有片段的应用程序。它有一个JavaScript接口,它在主活动中被调用并具有片段替换逻辑。当应用程序在前台时一切正常,但当应用程序在后台时,片段事务替换不起作用。当我回到我的应用程序时,我仍然看到旧的碎片,并没有看到新的碎片。Android片段在后台交易
@JavascriptInterface
public void beginCall(String toast) {
FragmentTransaction fTrans;
taskFragment = TaskFragment.newInstance(toast,"");
fTrans = getSupportFragmentManager().beginTransaction();
fTrans.replace(R.id.frgmCont, taskFragment);
fTrans.commit();
}
什么是错?为什么片段事务不能在后台运行?
呼叫beginCall()从Activty的的onResume()方法也。 – Drv
@Drv,如果我这样做,它会打破应用逻辑 – inthy