【发布时间】:2018-10-08 12:52:07
【问题描述】:
我在我的应用程序中使用Branch IO,根据他们的documentation,我在我的活动中使用android:launchMode="singleTask"。
这是我的 AndroidManifest 的一些代码 sn-p。
<activity
android:name=".SplashScreen"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data
android:host="open"
android:scheme="com.package.name" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<!-- Branch App Links (optional) -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="app.link"
android:scheme="https" />
<!-- <data android:scheme="https" android:host="example-alternate.app.link" /> -->
</intent-filter>
</activity>
一切正常,除了当我在使用应用程序时按主页按钮并点击应用程序/启动器图标时,会调用启动屏幕活动的 onCreate 方法,这使得应用程序看起来像是从一开始就启动的。但是,如果我在使用应用程序时按下主页按钮并从最近的应用程序中打开它,则不会调用 onCreate 并且一切正常。
当从最近的应用和应用/启动器图标移到前台时,如何使应用行为保持一致?
我尝试删除 singleTask 启动模式,这使得从 App/Launcher 图标和最近的应用程序中完美启动,但是当点击分支 IO 链接时,会创建一个应用程序的新实例。我可以理解,要克服这个问题,只有他们要求将 singleTask 置于启动模式。
我已经在许多使用深层链接的应用程序中检查过这种情况,但它们没有这个问题!
我一定做错了,我看不到。
是否缺少某些东西或实施有误?
【问题讨论】:
-
您是在 onPause 还是 onStop 上完成了您的应用程序?这只发生在您的应用实例停止时。
-
不,我在 onPause/onStop 中什么也没做。即使是这样,从最近的应用程序打开时它如何正常工作? @NoBody
-
您可以在此处添加您的活动代码吗?
标签: android android-activity deep-linking branch.io android-deep-link