从启动器运行应用程序A时,有时也会运行应用程序B

时间:2019-09-14 08:47:08

标签: android manifest

我有一个绑定到服务的Gallery应用程序(A)。 我有第二个透明应用程序(B),它只运行未绑定的服务并自行关闭。 有时-在启动器中运行应用程序B时,它也会瞬间运行应用程序A。我看到应用程序A的布局出现并消失了。 我怀疑清单中的某些内容定义错误:launchMode或taskaffinty。 有什么想法吗?

   <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

<activity android:name="com.temp.tempApp.GalleryActivity"
            android:theme="@style/AppTheme.NoActionBar"
            android:icon="@mipmap/ic_launcher"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:label="@string/app_label_gallery"
            android:excludeFromRecents="true"
            android:screenOrientation="portrait"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


       <activity android:name="com.temp.tempApp.MainActivity"
            android:icon="@mipmap/ic_launcher"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:launchMode="singleTask"
            android:label="@string/app_label"
            android:theme="@style/Theme.Transparent"
            android:windowSoftInputMode="stateHidden|adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>
        </activity>
        <service android:name="com.temp.tempApp.MainService"  android:enabled="true"
            android:exported="false">
        </service>

1 个答案:

答案 0 :(得分:0)

找到了答案,以下一项解决了它: 1.向每个活动添加特定的相关性值“ android:taskAffinity =” com.example.MainActivity“” 2.两种活动的图标不同。

希望它对以后的人有帮助