我尝试通过从最近的应用程序中滑动来终止该应用程序,但该应用程序仍然存在。有一个单例对象在 Application 类中保存会话信息。当我刷卡后重新启动应用程序时,这个单例仍然保留。所以仍然有一个有效的会话。这种情况有时会发生,并且每次尝试都无法重现。它可能(我不确定)在使用 Uri 开始活动后发生
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("myapp://someactivity")
startActivity(intent)
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml 中的目标活动:
<activity
android:name="TargetActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
<data android:scheme="myapp2" />
</intent-filter>
<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="@string/url_host"
android:pathPrefix="@string/url1"
android:scheme="https" />
<data
android:host="@string/url_host"
android:pathPrefix="@string/url_2"
android:scheme="https" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我在各种 Android 版本(6、7、8)上都遇到过这个问题。
android ×1