• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps What's the deal with ndroid.intent.category.DEFAULT?

DaveInNYC

Member
I am not entirely clear on when one should use android.intent.category.DEFAULT in their intent filter. Most of the examples I have seen use it without explaining why.

In my particular case, I am trying to have my app launch when the device is placed in the car dock. However, it would not launch until I added the default category:

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.CAR_DOCK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Now here is the strange part: when I call getIntent() in my activity, the only category it contains is android.intent.category.CAR_DOCK. I thought that a particular category needed to be in an intent filter only if that category was in the intent that was broadcast, but in this case the default category was NOT in the intent, yet it still seems to be required. What am I missing?
 
Android Docs said:
Set if the activity should be an option for the default action (center press) to perform on a piece of data. Setting this will hide from the user any activities without it set when performing an action on some data. Note that this is normal -not- set in the Intent when initiating an action it is for use in intent filters specified in packages.
From:
Intent | Android Developers

Which is cryptic, but I assumed it meant that if you release an application with multiple activities, only the activities with "DEFAULT" specified will show up in the list of apps. I could be wrong, maybe I'll just have to try it.
 
Back
Top Bottom