在 Android 设备上运行一次时,Android 应用安装了 3 次 [英] Android app gets installed 3 times when ran once on android device

查看:20
本文介绍了在 Android 设备上运行一次时,Android 应用安装了 3 次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的手机上运行我的应用程序时,它被安装了 3 次,不知道为什么会这样,有人知道我如何解决这个问题吗?

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?

我的清单

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

推荐答案

该应用程序仅安装一次.但是您在应用程序启动器中看到它 3 次.应用程序启动器中的每个图标都对应于您的一项活动.这是由您为每个活动指定的意图过滤器引起的:

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>

意图过滤器表示可以启动 Activity,并且它的带有相应标签的图标应该在应用程序启动器中可见.如果您按下启动器中的图标,您将启动相应的活动.通常,您在应用程序中只有一个这样的活动.

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.

顺便说一句:Android 上的应用程序通过 AndroidManifest.xml 文件中指定的包来区分.因此,除非您更改软件包,否则您无法多次安装该应用.

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.

这篇关于在 Android 设备上运行一次时,Android 应用安装了 3 次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆