![](/img/trans.png)
[英]Intent opens the app immediately when app is in background -Android
[英]Receive data intent opens second app when app is opened
<activity
android:name=".activitys.SplashScreen"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
當應用程序啟動時,嘗試共享文本並且應用程序正在啟動,但如果通過 android 導航按鈕打開上一個應用程序,我會看到 2 個我的應用程序示例。 如何檢查應用程序是否已啟動並重新打開而不是一次打開第二個
簡單的答案:您需要添加
android:launchMode="singleInstance"
在您的活動括號內(例如,在 android:name=".activitys.SplashScreen" 下方)
更好的答案: Go 通過這篇文章了解不同類型的啟動模式: https://medium.com/@iammert/android-launchmode-visualized-8843fc833dbe
最佳答案:通讀有關任務的文檔: https://developer.android.com/guide/components/activities/tasks-and-back-stack
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.