接收数据意图在打开应用程序时打开第二个应用程序

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"

在您的 activity 括号内(例如 android:name=".activitys.SplashScreen" 下方)

更好的答案:阅读本文以了解不同类型的启动模式:https://medium.com/@iammert/android-launchmode-visualized-8843fc833dbe

最佳答案:通读有关任务的文档:https://developer.android.com/guide/components/activities/tasks-and-back-stack