Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose of using CATEGORY_HOME in android manifest?

What is the alternative to removing the following from AndroidManifest:

 <activity           

    android:name="com.apper.main.UserActivity"
    android:label="@string/app_name"        
    android:launchMode="singleTask"
    android:clearTaskOnLaunch="true"
    android:stateNotNeeded="true" >
        <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>

I also found that after removing the above line, there was no impact to my android application. What's the main use of this category and what's the alternative to it.

If the intent of this category is to launch the home screen then it can be done by the following:

Intent homeIntent= new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);

This above code will launch the home screen but why the line in the android manifest ? What's the purpose as removing the line from here does nothing change the application ?

like image 534
My God Avatar asked Jul 09 '13 15:07

My God


2 Answers

What's the main use of this category

It, coupled with ACTION_MAIN, identifies a replacement home screen.

what's the alternative to it

Not having it. Either you have this category, or you do not.

like image 157
CommonsWare Avatar answered Oct 02 '22 12:10

CommonsWare


The category HOME is used to declare your application as a Home launcher. By putting this in the manifest then user will have the option to have your application open upon pressing the home button.

This is typically used when creating an application that will be used in a kiosk mode.

I do not believe there is an alternative to make an application a home launcher.

Documentation

like image 34
TronicZomB Avatar answered Oct 02 '22 14:10

TronicZomB