Why is the HOME category required?

I have these categories defined in the 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 delete the line -

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

This does not affect any part of the functionality of the application, and I can see my application in the launch list of my main Android device.

However, if I delete the last line -

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

I see a change that my application has disappeared from the startup list of the main screen of my Android device.

So my question is what is the purpose of this HOME category and what is its general use.

If the sole purpose of this category is to launch the main screen, as indicated in the android documents , then this can also be done as follows:

 Intent homeIntent= new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(homeIntent); 
+6
source share
1 answer
  <category android:name="android.intent.category.HOME"/> 

indicates that when you press the home button, your application will be displayed as an option to start a home launch or your home activity (along with all applications that have this category in their manifest for activity). To be simpler, whenever you click the Home button, all applications installed on your phone that have the CATEGORY.HOME and Action_Main categories in the intent filter in your AndroidManifest.xml will be listed (if you did not select which or the default application) to choose for the user to choose which HOME they want to run.

+17
source

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


All Articles