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


Last Updated:

  1. DaveInNYC

    DaveInNYC Well-Known Member This Topic's Starter

    Joined:
    Nov 7, 2009
    Messages:
    52
    Likes Received:
    3
    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?
     

    Advertisement
  2. DaveInNYC

    DaveInNYC Well-Known Member This Topic's Starter

    Joined:
    Nov 7, 2009
    Messages:
    52
    Likes Received:
    3
    Nobody knows this? I am sorta surprised, as this *seems* like an Android 101 type of question. :confused:
     
  3. dodald

    dodald Member

    Joined:
    Nov 8, 2009
    Messages:
    18
    Likes Received:
    4
    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.
     

Share This Page

Loading...