Search code examples
androidandroid-manifestdocking

App not starting when docked


After browsing the web I have found out that this code is supposed to start a app when docked:

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

The problem is that this does not start the app when the phone is docked. What am I doing wrong?

Edit: Nothing happens when I dock it in a desk dock.


Solution

  • "Nothing happens when I dock it in a desk dock."

    Note the code you have written will only work for a car dock. Hence you have added the word car dock in the category.

    To launch an app when in any Dock the following is required

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

    Note the addition of desk dock