How to set apps as default or let the user select the app?
You need to register an Intent Filter for the file types, actions, or categories for which you want your app to be the default app. The user will then be able to choose your app as the default app if they want to.
Look here for more information on Intents and Intent Filters.
Forcing your app as the default app for something is only possible with root access.
So my question is, what mime types I have to add to the intent filters in the android manifest file?
mimetype
it's just standard of describing content, and it's next processing. This is not something new in Android, you can check more information about Media Types Wiki page. This information about mimetype
attribute in the the Android Documentation:
android:mimeType - A MIME media type, such as image/jpeg or audio/mpeg4-generic. The subtype can be the asterisk wildcard to indicate that any subtype matches
However as you can see the vnd
prefix on a MIME type is a "vendor prefix", meaning that it is not an official IETF MIME type. So you will need to check this type for each application. Just some examples, what we have below.
Note! In order to set default application, you need to specify android.intent.action
first. Because it's main flags between process interaction, so Launcher (for ex.) won't have mimetype
, and only intent actions android.intent.action.MAIN
, android.intent.action.SET_WALLPAPER
.
Camera:
<data android:mimeType="vnd.android.cursor.dir/image" />
<data android:mimeType="vnd.android.cursor.dir/video" />
Image/Video/Audio:
<data android:mimeType="video/*" />
<data android:mimeType="video/mpeg4" />
<data android:mimeType="video/mp4" />
<data android:mimeType="video/3gp" />
......
<data android:mimeType="image/*" />
<data android:mimeType="application/sdp" />
......
<data android:mimeType="audio/x-mpegurl" />
<data android:mimeType="audio/mpegurl" />
<data android:mimeType="application/vnd.apple.mpegurl" />
<data android:mimeType="application/x-mpegurl" />
....
Contacts:
<data android:mimeType="vnd.android.cursor.item/phone" />
<data android:mimeType="vnd.android.cursor.item/person" />
<data android:mimeType="vnd.android.cursor.dir/calls" />
Browser:
<data android:mimeType="application/xhtml+xml"/>
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
<data android:mimeType="vnd.android.cursor.item/postal-address" />
<data android:mimeType="vnd.android.cursor.dir/bookmark"/>
<data android:mimeType="vnd.android.cursor.item/download"/>
I am not sure but using Intent.createChooser()
you will get the solution
click here