在 Android 中,Detach app 如何通过 intent 调用它?
In Android how Detach app from the one invoked it through intent?
我在具有深度linking 概念的whats-app 上单击link 后启动了我的应用程序。之后我按主页,每次我启动应用程序 whats-app 时它都会打开我的应用程序。看起来应用程序仍然附加。对解决这个问题有帮助吗?
在这里您可以找到如何在您自己的应用堆栈中启动 "UP" 的官方指南:http://developer.android.com/training/implementing-navigation/ancestral.html
您必须像这样在清单中定义您的 "home" activity:
<activity
android:name=".DeepLinkActivity"
android:parentActivityName="com.my.app.HomeActivity">
然后按下向上键,您将处理此代码:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.
TaskStackBuilder.create(this)
// Add all of this activity's parents to the back stack
.addNextIntentWithParentStack(upIntent)
// Navigate up to the closest parent
.startActivities();
} else {
// This activity is part of this app's task, so simply
// navigate up to the logical parent activity.
NavUtils.navigateUpTo(this, upIntent);
}
我在具有深度linking 概念的whats-app 上单击link 后启动了我的应用程序。之后我按主页,每次我启动应用程序 whats-app 时它都会打开我的应用程序。看起来应用程序仍然附加。对解决这个问题有帮助吗?
在这里您可以找到如何在您自己的应用堆栈中启动 "UP" 的官方指南:http://developer.android.com/training/implementing-navigation/ancestral.html
您必须像这样在清单中定义您的 "home" activity:
<activity
android:name=".DeepLinkActivity"
android:parentActivityName="com.my.app.HomeActivity">
然后按下向上键,您将处理此代码:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.
TaskStackBuilder.create(this)
// Add all of this activity's parents to the back stack
.addNextIntentWithParentStack(upIntent)
// Navigate up to the closest parent
.startActivities();
} else {
// This activity is part of this app's task, so simply
// navigate up to the logical parent activity.
NavUtils.navigateUpTo(this, upIntent);
}