Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is category HOME required? [duplicate]

I have these categories defined in my application manifest file:

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

If I remove the line -

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

It does not affect any part of the application functionality and I can see my application in the home screen launcher list of my android device.

However, If I remove the last line -

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

I see the change that my application gets disappeared from home screen launcher list of my android device.

So my question is what's the purpose of this category HOME and what's its common use.

If the only purpose of this category is to launch the home screen as mentioned in the android docs, then this I can do by the following also:

Intent homeIntent= new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);
like image 939
My God Avatar asked Jul 11 '13 09:07

My God


People also ask

Why would a home have two listings?

A multiple listing service is a collection of private databases used by real estate brokers who agree to share their listing agreements with one another to locate ready, willing and able buyers for properties more quickly than they could on their own.

What is category in intent filter?

Adds a category name to an intent filter. A string containing additional information about the kind of component that should handle the intent. Example of common categories: CATEGORY_BROWSABLE: The target activity allows itself to be started by a web browser to display data referenced by a link.

What is category launcher?

category -- Gives additional information about the action to execute. For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level application, while CATEGORY_ALTERNATIVE means it should be included in a list of alternative actions the user can perform on a piece of data.


1 Answers

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

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.

like image 157
user936414 Avatar answered Nov 15 '22 15:11

user936414