Android app gets installed 3 times when ran once on android device [closed]

一个人想着一个人 提交于 2019-12-13 01:27:37

问题


When running my app on my phone it gets installed 3 times, not sure why it does this, anyone know how I can solve this?

my manifest

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <uses-library android:name="com.google.android.maps" />
    <activity
        android:name=".MyTravelManagerActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <activity android:name=".Main"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".OpenMap"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>


回答1:


The app is installed only once. But you see it 3 times in the application launcher. Each icon in the application launcher corresponds to one of your activities. It is caused by the intent filter you specified for each of the activities:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

The intent filter says that the activity can be launched and it's icon with a corresponding label should be visible in the application launcher. If you press the icon in the launcher, you will start the corresponding activity. Typically, you have only one such activity in the application.

Btw: Apps on Android are distinguished by the package specified in AndroidManifest.xml file. Therefore unless you change the package, you can't install the app multiple times.



来源:https://stackoverflow.com/questions/12867455/android-app-gets-installed-3-times-when-ran-once-on-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!