Android Application creating two launcher icons

2019-04-29 10:18发布

I am having a very confusing problem with an application I have been working on for some time. Suddenly, when running my application, I found an immediate force close upon launch.

Upon further investigation, I found two launcher icons in my launcher. One of which will either resume the application if it is running or force close if it is not running. The second will behave as normal - launches the application normally and resumes normally.

I am very confused, as I was not doing anything (that I can think of) to cause this problem. I was not changing anything whatsoever in the manifest and just implementing a few new methods to change colors in my app faster.

These problems persist identically in all my emulators and devices whether I turn off the phone, manually kill the app or uninstall/reinstall the app. A simple ctrl+z did not work. To clarify - all I would like is to go back to have one launcher icon to launch my application normally (nothing special goes on at all).

Update:

I am now presented with an immediate force close on launching from either icon. I did find code within two activities within my Manifest displaying and changing the second line from .LAUNCHER to .DEFAULT did fix my original problem. However, I am now always presented with an immediate force close...there are now problems (that I can see) within my originally launcher activity...I am having a lot of trouble attempting to fix this (have no idea what to do) and am starting to become VERY worried!

Update 2:

I found my problems and I thank you guys for all your help! I actually had two separate and unrelated problems that occurred at the same time. Number one - two icons in my launcher: caused because I had two activities with a

5条回答
地球回转人心会变
2楼-- · 2019-04-29 11:01

Well , I was facing same problem. Problem was when I RUN app, it was creating two icons one with name MyApp and other with SplashActivity. When I was attempting to uninstall SplashActivity (named app), in Confirmation message it was saying

SplashActivity is part of MyApp , sure you want to uninstall?

After looking at some references, concluded that when we put

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

under any activity, android thinks that this is the MAIN entry point of App. And creates an launcher icon for that activity. but name was kept as acivityName.

So Finally by changing Activity tag of SplashActivity from

 <activity
    android:name=".activities.SplashActivity"
    android:label="@string/title_activity_splash"
    android:theme="@style/SplashTheme">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
 </activity>

to

<activity
    android:name=".activities.SplashActivity"
    android:label="@string/app_name"
    android:theme="@style/SplashTheme">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

It solved my issue of multiple icons and launcher icon name as activityName instead of appName.

查看更多
成全新的幸福
3楼-- · 2019-04-29 11:01

In my case, helped somethning like that

The old one lines from the manifest file

Splash screen activity

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

Main Activity

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

And the new one

Splash screen activity

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

Main Activity

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

Just remove in Main Activity this line below

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

And that's it !

查看更多
We Are One
4楼-- · 2019-04-29 11:06

Actually Android Launcher displays all activities with category LAUNCHER not applications.

If your application contains more than 1 activity, you have to use action MAIN and category LAUNCHER for your default activity (initial screen) of application only, not for all activities you used in application. If you put same for every activity in application it will be displayed in Android Launcher.

Please read about the Intent Actions and Categories, you will understood.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-04-29 11:11

in AndroidMenifest.xml file you have to remove two or three android name i.e

<activity
    android:name=".SplashScreen"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
查看更多
趁早两清
6楼-- · 2019-04-29 11:13

two activities have

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

remove second one

查看更多
登录 后发表回答