Adding app launch icon to the home screen - android

I would like to place the app launch icon on the home screen once the user installs my android app. This should be done even if the user does not open the app.
I have tried adding "category android:name="android.intent.category.HOME" in the manifest file for my main activity. But this does not work.
Any pointers on how solve this issue?
Thanks
Srao

I think this would be enough:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Related

Multi icon in screen Android [duplicate]

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 icon is for the main activity and the second is for the subactivity. I don't want/need an icon for the subactivity.
Does anyone know how to turn this off in my app code, so that only the icon for the main activity is installed? Any information you can provide is greatly appreciated!
Thanks,
MobiKnow
Does your application manifest list an intent filter under your sub-activity that matches the main launcher?
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Make sure that your sub-activity is not filtering for these intents.
Edit: Just to be very clear, make sure the above lines are not listed under your sub-activity. That intent filter lets the Android system know that you intend for it to be listed as an entry point to your application.
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
It creates two App icon because you must have added the given filter to two of your activities. See manifest.
<category android:name="android.intent.category.MAIN" />
Remove the above statement from the other one. Then you are good to go.
Like in the other answers,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
Was the culprit. However, in my manifest I only had one activity with that intent filter. As it turns out, I am using a library I built and it has an activity declared in it's manifest which uses that intent filter. So, in short, be sure your app's manifest and dependencies, if any, only have one activity with the intent filter.
I guess that in your AndroidManifest.xml, you've got both activities having the LAUNCHER intent-filter. Remove it from the second activity, and you should be set!
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.
I was searching answer to exactly the same question. It appears the only thing needed (in addition to recommendations on removing MAIN and LAUNCHER intent filter) is to rebuild your project - that will clean things up and upon next launch I saw single icon on my device (just running application on device after changes did not help).
if anyone run into this issue using Pebble SDK. I noticed PebbleKit Androidmanifest.xml holds a LAUNCHER activity as well. This is what caused it for me. Just remove this part. It will not effect Pebble functionality.
SIMPLE answer..
REMOVE:
<category android:name="android.intent.category.LAUNCHER" />
From your AndroidManifest.xml
Leave your intent-filter alone.
<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.

Android app showing 2 icon in device while testing

I'm new to android and Developing very basic App. I have completed my development but when ever I debug my app in device. It shows 2 icon. I'm facing this problem after implementing Splash Screen in my app. Please suggest me how to overcome. My manifest
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/icc"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<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>
<activity android:name=".Login_page">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In your manifest file -
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This piece of code means which activity will first start when you launch the app. But you have put this code in both of your activities hence Android provides a separate launcher for both the activities and you see two icons.
So remove the above code from one of the activities. Just let it remain in the Activity you want to start first when your app launches.
TO have a icon on the launcher screen you need action of the activity to be action_main and category to be launcher and your both activity qualifies the criteria for this.
You should change your login_activity category to default or simply remove the category.
You can start your login activity from splash activity.
I hope it helps you.

How to end a launcher completely?

My application works as a launcher. But, I guess I did something wrong by making it a launcher. For instance, the user selects my application as Default Launcher (clicks 'Always'). However, when the user exits from the application, it appears again, because it's the default launcher. How can I fix it?
<activity
android:name="com.comeks.cocuktablet.Main"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The code comes from my manifest. I also want to make MAIN activity launcher.
Edit:
I realized my exact error. I also wrote a code to start my app on boot. The problem is that when I close my device and open it again, I cannot exit from it.
Thank you for your all answers. I solved my problem by calling Android's home launcher while exiting from app.
Just remove
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
from intent-filter

In android every .java file becomes an app on the phone!

I have 6 .java files under one package.In eclipse, after I export the .apk and install the app on the phone or if i run the app on the emulator, there are 6 applications created, one for each .java file! The java files are different screens in my app.So i can open any java file by clicking on the icon in the menu.I only want one of them to be openable through the icon in the menu. So basically, only one icon should be seen in the main menu, which upon clicking opens the first activity in the manifest file!
Any idea whats wrong?
Thanks.
My assumption:
You registered all your Activities in the AndroidManifest (which is right) but as intent-filter you always used
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
That intent-filter tells Android to add the Activity to the launcher. Remove those Intent-filters (except one Activity that's going to be your main entry point) and it should work.
What does your manifest say? It might specify that all activities are shown as seperate apps...
Just check your AndroidManifest.xml file and modify your activity same as below code example:
<activity android:name=".MainActivity"
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=".SecondActivity"
android:label="SecondActivity">
</activity>
So if you mark the above code then you can easily come to know that the below code mention that this activity is going to be act as a launcher activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Try to mention the intent-filter action as MAIN and Category as Launcher only for your entry activity in your app.
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>.
Remove this for all other activities except the entry point for your app.
Hope this helps.

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

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 icon is for the main activity and the second is for the subactivity. I don't want/need an icon for the subactivity.
Does anyone know how to turn this off in my app code, so that only the icon for the main activity is installed? Any information you can provide is greatly appreciated!
Thanks,
MobiKnow
Does your application manifest list an intent filter under your sub-activity that matches the main launcher?
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Make sure that your sub-activity is not filtering for these intents.
Edit: Just to be very clear, make sure the above lines are not listed under your sub-activity. That intent filter lets the Android system know that you intend for it to be listed as an entry point to your application.
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
It creates two App icon because you must have added the given filter to two of your activities. See manifest.
<category android:name="android.intent.category.MAIN" />
Remove the above statement from the other one. Then you are good to go.
Like in the other answers,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
Was the culprit. However, in my manifest I only had one activity with that intent filter. As it turns out, I am using a library I built and it has an activity declared in it's manifest which uses that intent filter. So, in short, be sure your app's manifest and dependencies, if any, only have one activity with the intent filter.
I guess that in your AndroidManifest.xml, you've got both activities having the LAUNCHER intent-filter. Remove it from the second activity, and you should be set!
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.
I was searching answer to exactly the same question. It appears the only thing needed (in addition to recommendations on removing MAIN and LAUNCHER intent filter) is to rebuild your project - that will clean things up and upon next launch I saw single icon on my device (just running application on device after changes did not help).
if anyone run into this issue using Pebble SDK. I noticed PebbleKit Androidmanifest.xml holds a LAUNCHER activity as well. This is what caused it for me. Just remove this part. It will not effect Pebble functionality.
SIMPLE answer..
REMOVE:
<category android:name="android.intent.category.LAUNCHER" />
From your AndroidManifest.xml
Leave your intent-filter alone.
<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.

Categories

Resources