I want my application start automatically when the device is placed in the car doc. I find this useful code for manifest but I want to give user option with checkbox if he want to use this option.
<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" />
How to make this possible if user check option then app will be started when it is placed in the car dock, otherway not.
Use the above manifest entries for a broadcast reciever and not for a activity. And inside broadcast receiver you can check the preference and then launch the activity.
Edit:
Register the DockReciever with above manifest changes. If that does not work then use below action
you will have to check the state of the dock if you use this.