Android App Development: Two icons getting created and I only need one

后端 未结 10 2194
情书的邮戳
情书的邮戳 2020-12-14 00:14

I am writing an Android App that has one main activity and one subactivity. When I install the app on my phone to test it out, I get two icons instead of one. The first ic

相关标签:
10条回答
  • 2020-12-14 00:50
    <intent-filter android:icon=”drawable resource” android:priority=”Integer” /intent-filter>
    

    Priorities are set for the parent component. This setting may help you to set the parent icon for your Android app development.

    0 讨论(0)
  • 2020-12-14 00:51

    You have

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

    along with

    android:icon="@drawable/icon.png"
    

    set for both activities.

    What that means is that this is a launcher icon, put me on the home screen. Only set those for the activit(ies/y) you want on the home screen.

    0 讨论(0)
  • 2020-12-14 00:52

    We have the same problem but i fixed it this way before my code below in manifest

    <application
            android:debuggable="true"
            android:allowBackup="true">
            <activity        android:name=".SplashActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name="com.noupdate.apptest_noupdate.MainActivity"
                android:icon="@drawable/ic_launcher"
                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>
    

    Notice that in the SplashActivity inside the intent is this code

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

    i only deleted the category

     <category android:name="android.intent.category.LAUNCHER" />
    

    So after i deleted the intent-filter category in splash it didn't install two app icon but only one for main the code will be like this notice that the intent-filter category is deleted

    <application
            android:debuggable="true"
            android:allowBackup="true">
            <activity     android:name=".SplashActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                </intent-filter>
            </activity>
            <activity
                android:name="com.noupdate.apptest_noupdate.MainActivity"
                android:icon="@drawable/ic_launcher"
                android:theme="@android:style/Theme.NoTitleBar"
                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>
    

    it really helps

    0 讨论(0)
  • I'm going to guess that in your AndroidManifest.xml, you've got both activities having the LAUNCHER itnent-filter. Remove it from the second activity, and you should be set.

    0 讨论(0)
提交回复
热议问题