Difference between Category Home and Category Launcher - android

I am not clear about what is the difference between category home and category launcher. From Android documentation page:
CATEGORY_HOME : This is the home activity, that is the first activity
that is displayed when the device boots.
CATEGORY_LAUNCHER : Should be displayed in the top-level launcher.
To test the difference I made a simple app with this manifest:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".IntentCategoriesActivity"
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=".Second"
android:label="Whatever" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>
But all I see is my launcher activity not the second activity.
Can somebody please explain what am I missing? Thanks.

android.intent.category.HOME is used for Home Screen activities like ADW Launcher, Launcher Pro, etc. If you want to create a new home screen use this.
android.intent.category.LAUNCHER is used to specify which of your activities can be launched. I.e. which ones show up in the app drawer.

android.intent.category.HOME - To be a launcher - this activity is homescreen
android.intent.category.LAUNCHER - To be in launcher - this activity is visible in menu

In one manifest file ,there is only the first main is useful ,the second android.intent.action.MAIN is useless.

Related

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.

My android application always be in launcher list

hi i am new in android application Development
after successfully Developed android application when i install apk of that application it is always under launcher list, and always ask to select default launcher when i press Home key. How to prevent app. to be in list under launcher.
manifest file code are as follow.
//Manifest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.dewebclient.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.dewebclient.IpConfigure" ></activity>
<activity android:name="com.example.dewebclient.WebViewClientDE" />
<!--android:theme="#android:style/Theme.NoTitleBar"-->
</application>
Remove below line from your AndroidManifest.xml file.
<category android:name="android.intent.category.HOME" />
Explanation :
The category HOME is used to declare your application as a Home launcher. By putting this in the AndroidManifest.xml, user will have the option to have your application open upon pressing the home button.
According to Developer Docs.
This is the home activity, that is the first activity that is displayed when the device boots.
<category android:name="android.intent.category.HOME" />
Remove above line from AndroidManifest.xml .
<category android:name="android.intent.category.HOME"/>
Remove this and check.
This indicates that when you press home button, your app will be listed as an option to launch the launcher home or your home activity (along with all the applications which have this category in their manifest for an activity). To be more simple, whenever you press the home button, all the applications installed in your phone which have CATEGORY.HOME category and Action_Main in intent-filter in their AndroidManifest.xml will be listed (unless you have chosen some application as default) in a chooser for the user to select which HOME they want to launch.
change your intent filter look like below.
and relaunch application.
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
referenc this link

Setting two different labels for the Launcher and the first activity

This should be a simple fix. My problem is that my launcher name is the same as my first activity. #string/app_name is my actual application name that I want it to show, but it is showing my first activity "Drafts" for the launcher. If I take out the #string/activity_drafts then the Launcher is correct, but then the first activity is my app_name which is not the behaviour I am looking for. I just want two seperate names for the launcher and the first activity's title and I'm not really sure what is going on here.
Manifest.xml
<application android:name="com.jordan.dictation.Dictation2Go"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/dp_launcher2"
android:logo="#drawable/dp_white_logo"
android:label="#string/app_name"
android:theme="#style/MyTheme">
<activity
android:name="com.jordan.dictation.Draft_Activity"
android:screenOrientation="portrait"
android:label="#string/activity_drafts"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am not sure how to do it in manifest file, however you can do it programmatically in your activity:
setTitle("Activity title");
or
getActionBar().setTitle("Activity title");
EDIT: GOT IT!
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name="com.example.so1.MainActivity"
android:label="ACTIVITY NAME"
>
<intent-filter android:label="APP NAME">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Note: Doing this might result in unexpected behavior upon device restart, e.g. with an unmodified Samsung S3, a shortcut on the home screen will be renamed to the activity's label. (See https://stackoverflow.com/a/7250902)
The icon and label set for an intent filter are used to
represent a component whenever the component is
presented to the user as fulfilling the function advertised
by the filter. For example, a filter with
" android.intent.action.MAIN " and
" android.intent.category.LAUNCHER " settings
advertises an activity as one that initiates an
application — that is, as one that should be displayed in
the application launcher. The icon and label set in the
filter are therefore the ones displayed in the launcher.

Every Activity of my application is shown as an app on its own

Just like the title says, for some reason which I dont understand, Every Activity I create in my application is shown as an icon for an application on the phone's app menu.
Could someone please help me solve this wierd problem?
If you need some code just ask for it (I dont know which code is related with these kind of stuff).
Thanks!
In your manifest remove these lines from all Activities except the one you want to open on:
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Example:
<activity
android:name="your.package.name.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<!-- This line declares this Activity as the start point -->
<action android:name="android.intent.action.MAIN" />
<!-- This line adds a launcher icon -->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="your.package.name.OtherActivity"
android:label="#string/app_name" >
</activity>
In your manifest file you must have set launcher intent-filter for all of your activities.. Keep launcher intent-filter only in launcher activity..

How to make sure that the launcher activity always run when the app is launched from the home

I have 2 activities in my app. The A activity is the launcher one. When I run the app the very first time, the launcher activity runs, but when I press the home button and restart the app from there by clicking the app icon, I always get the B activity running.
I want to make sure that the activity A should always run when starting the app.
This is the manifest code:
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name="com.velosys.smsManager.Activities.a"
android:clearTaskOnLaunch="true"
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="com.velosys.smsManager.Activities.b" />
</application>
I have searched a lot for this but did not get any clue.
Maybe android:launchMode="singleInstance" on activity B will get it done?

Categories

Resources