简体   繁体   English

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

[英]When running application A from the launcher it sometimes also runs application B

I have one Gallery application (A) that binds to a service. 我有一个绑定到服务的Gallery应用程序(A)。 I have second transparent application (B) that just runs a service unbound and closes itself. 我有第二个透明应用程序(B),它只运行未绑定的服务并自行关闭。 sometimes - when running application B from the launcher it also runs for a split of a second the application A. I see the layout of application A appears and disappear. 有时-在启动器中运行应用程序B时,它也会瞬间运行应用程序A。我看到应用程序A的布局出现并消失了。 I suspect that something in the manifest is defined wrong : launchMode or taskaffinty. 我怀疑清单中的某些内容定义错误:launchMode或taskaffinty。 any ideas? 有任何想法吗?

   <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>

Found the answer, one of the following fixed it: 1. add to each activity specific afinity value "android:taskAffinity="com.example.MainActivity"" 2. different icons for the 2 activities. 找到了答案,以下一项解决了它:1.向每个活动添加特定的亲和力值“ android:taskAffinity =“ com.example.MainActivity”“。2.这两个活动使用不同的图标。

hope it helps somebody in the future 希望对将来有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM