【发布时间】:2016-03-29 13:35:22
【问题描述】:
我正在使用多屏应用
我的应用程序从启动(启动器)-> 主屏幕-> 子屏幕启动。
当用户点击 URL 应用程序直接跳转到子屏幕(应用程序需要)。
但是当用户点击 URL 时,会启动一个我不想要的新应用程序实例。我想关闭现有应用程序并使用子屏幕启动新应用程序。每个活动都有android:launchMode="singleTop"
【问题讨论】:
我正在使用多屏应用
我的应用程序从启动(启动器)-> 主屏幕-> 子屏幕启动。
当用户点击 URL 应用程序直接跳转到子屏幕(应用程序需要)。
但是当用户点击 URL 时,会启动一个我不想要的新应用程序实例。我想关闭现有应用程序并使用子屏幕启动新应用程序。每个活动都有android:launchMode="singleTop"
【问题讨论】:
为了启动新的应用程序,我发现了这个解决方案,它对我来说很好用
Intent intent = new Intent(Firstctivity.this, SecondActivity.class);
intent .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent );
finish();
它将关闭正在进行的Task 并为我创建一个新的.. :)
【讨论】: