【问题标题】:Backstack messed up after starting browser with startActivity使用 startActivity 启动浏览器后,Backstack 搞砸了
【发布时间】:2014-09-27 00:03:02
【问题描述】:

目前我有这个设置:

活动 A 是主要的

活动 A 启动活动 B

B 给自己添加一个 Fragment: getFragmentManager().beginTransaction().add(android.R.id.content, new FirstFragment()).commit();

然后在交互之后,FirstFragment 被替换为 SecondFragment 并被添加到后台堆栈中: getFragmentManager().beginTransaction().replace(android.R.id.content, new SecondFragment()).addToBackStack(null).commit();

如果用户点击这个Fragment,它会启动浏览器:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(licenceInfo[2].toString()));
browserIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(browserIntent);

但是当用户使用后退按钮从浏览器返回到我的应用程序后,它就搞砸了。 SecondFragmentdrawn on FirstFragment。 :S 如果我点击返回,SecondFragment 将不再被绘制。最后还有一件很烦人的事:返回Activity A的时候,它的onCreate方法被调用了。

如果我不从SecondFragment 启动浏览器,一切都很好。

【问题讨论】:

    标签: android android-intent android-fragments


    【解决方案1】:

    好的,我想这是我的 ROM 的故障。我使用定制的 KitKat ROM,它可以与我的旧 HTC Sensation 设备一起使用。此 ROM 产生上述行为。我刚刚尝试了一部 Android 4.2 手机和 4.4 模拟器,两者都正常工作...

    【讨论】:

      猜你喜欢
      • 2010-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      • 1970-01-01
      • 2014-02-02
      相关资源
      最近更新 更多