Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "category" in the manifest mean?

The documentation says you can specify a custom category.

  • When, why and how would you do it?
  • What would be the use of it?
like image 937
Suchi Avatar asked Jul 21 '11 21:07

Suchi


People also ask

What is category in manifest?

You can specify categories in your applications manifest that lets the system know that you application can handle the intent category. For example, by putting a ALTERNATIVE category, other apps in the system know that your app can handle that category without specifically knowing the action name!

What is category in intent?

Categories are used for implicit Intents. So, If your Activity can be started by an implicit Intent when no other specific category is assigned to activity, activity's Intent filter should include this category. (even if you have other categories in the Intent filter).

What is a category in android?

You can choose a category and add tags to your app or game in Play Console. Categories and tags help users to search for and discover the most relevant apps in the Play Store. Users can view apps by using a browser and the Google Play app.

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

The way I understand it, categories are public directives to the android operating system(and other apps) that represent different categories that your app should be a part of.

Example

  • When the launcher icon is tapped on the home screen, the home application looks through every installed app's manifest for the HOME category -- and if so it displays it in the app drawer.

However, there's more. You can specify categories in your applications manifest that lets the system know that you application can handle the intent category. For example, by putting a ALTERNATIVE category, other apps in the system know that your app can handle that category without specifically knowing the action name! In the following example, custom intent categories are passed through this intent, which is filtered and the corresponding object gets edited(taken from the Notes example app):

<intent-filter android:label="@string/resolve_title">
 <action android:name="com.android.notepad.action.EDIT_TITLE" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.ALTERNATIVE" />
 <category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
 <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>

By registering this intent filter in an <activity /> tag, you can edit a "note". The intent data would contain the note, and the intent would get routed to the activity that this filter is registered in.

In Conclusion:

There isn't really a reason you'd use a custom category. They are for Android, and thus don't really make sense in application use. But, if you choose to use them, they can be used in the methods described above. "They provide some specific semantic rules, and if those rules are useful to you then feel free to use them"(Hackbod).

like image 178
hwrdprkns Avatar answered Oct 07 '22 09:10

hwrdprkns