【问题标题】:Intent Flag doesn't work for physical button in androidIntent Flag 不适用于 android 中的物理按钮
【发布时间】:2017-08-27 16:56:36
【问题描述】:

我想创建一个简单的应用程序,它有两个活动...我想在不执行 OnDestroy(); 我希望那里发生 OnPause() ;

我可以通过使用下面这样的flah来实现它。

Intent intent = new Intent(secondActivity.this, firstSecond.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);

但该标志仅适用于当前活动内的 BackButton。如果我点击手机中的后退按钮,标志不起作用.....我该怎么办????有什么帮助吗??

提前致谢

【问题讨论】:

    标签: android android-intent activity-lifecycle onpause ondestroy


    【解决方案1】:

    覆盖 onBackPressed() 并改为执行相同的代码:

    Intent intent = new Intent(secondActivity.this, firstSecond.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多