Android application creating two launch icons

I had a very confusing issue with an application that I had been working on for some time. Suddenly, when I started my application, I immediately started to start.

After further investigation, I found two launch icons in my launcher. One of them will either resume the application if it works, or close if it is not running. The second will behave as usual - it starts the application normally and resumes normally.

I am very confused because I did not do anything (that I can think of) to cause this problem. I didn’t change anything in the manifest and just used several new methods to change colors in the application more quickly.

These problems persist the same in all my emulators and devices, whether I turn off the phone, manually kill the application, or uninstall / reinstall the application. Simple ctrl + z does not work. To clarify, all I would like is to return to a single launcher icon to launch my application normally (nothing special happens at all).

Update:

Now I got immediate power when starting from any icon. I found the code in two actions in my manifest, displaying and changing the second line from .LAUNCHER to .DEFAULT, fixed my original problem. However, I am now always haunted by immediate power ... now there are problems (which I see) in my initial start-up activities ... I have many problems trying to fix this (I don’t know what to do), and I begin to become VERY CONCERNED!

Update 2:

I found my problems and I thank you guys for your help! I actually had two separate and unrelated problems that arose simultaneously. Number one - two icons in my launcher: due to the fact that I had two actions with

+6
source share
5 answers

two actions have

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

remove second

+24
source

In fact, Android Launcher displays all actions with the LAUNCHER category, not applications.

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

Read about actions and categories of intent that you understand.

+2
source

Well, I faced the same problem. The problem was when I ran the RUN application, it created two icons named MyApp and others with SplashActivity. When I tried to remove SplashActivity (named app), the Confirmation message said

SplashActivity is part of MyApp, do you want to delete?

After looking at some links, I came to the conclusion 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 considers this to be the MAIN entry point of the application. And creates a start icon for this activity. but the name was saved as acivityName.

So finally changing the SplashActivity activity tag 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> 

He solved my problem with multiple icons and a launch name icon as replacement_name instead of application name.

+2
source

In my case, something like that helped

Old lines from manifest file

Screen Saver Activity

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

Primary activity

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

And new

Screen Saver Activity

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

Primary activity

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

Just delete this line below in the main operation

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

What is it!

0
source

in the AndroidMenifest.xml file you need to delete two or three Android names ie

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

Source: https://habr.com/ru/post/904877/


All Articles