Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Application creating two launcher icons

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

like image 884
feztheforeigner Avatar asked Jan 02 '12 06:01

feztheforeigner


People also ask

Is it possible to have more than one launcher activity?

Yes, You can have more than one launcher activity in your application.

Can we have more than one launcher activity in Android?

On latest Android versions - If there are more than one launcher activities and if we don't put this category tag then the activity which is mentioned first in the Android manifest file will get launched as start-up activity.

What is adaptive icon?

Adaptive icons are a new drawable type, namely AdaptiveIconDrawable . You'll likely never need to work with the class directly, but to define it in XML and point to it from your manifest. You can do so using this format: <adaptive-icon> <background android:drawable="@[drawable|mipmap|color]/bar"/>

Is Android roundIcon required?

You must only use the android:roundIcon attribute if you require a different icon asset for circular masks, if for example the branding of your logo relies on a circular shape.


2 Answers

two activities have

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

remove second one

like image 93
Shailendra Singh Rajawat Avatar answered Oct 14 '22 15:10

Shailendra Singh Rajawat


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.

like image 24
Yugandhar Babu Avatar answered Oct 14 '22 15:10

Yugandhar Babu