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