Mar*_*lar 8 java android intentfilter android-manifest kotlin
Currently I'm trying to create a bunch of simple Android apps to replace the default apps with them.
I already saw in this post how to set the SMS app as default:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android-dir/mms-sms" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
But I was wondering how to achieve the same for these apps:
I already noticed that it's nearly impossible to set the app as default app programmatically without the user's interaction. This would be the main goal, but it would be also okay if the user can choose which application they want to use as the default application. But I want to be sure that the apps which I listed above are selectable. So my question is, what mime types do I have to add to the intent filters in the android manifest file?
所以我的问题是,我必须向 android 清单文件中的意图过滤器添加哪些 mime 类型?
mimetype
它只是描述内容的标准,它是下一步处理。这在 Android 中并不是什么新鲜事,您可以查看有关 Media Types Wiki 页面的更多信息。Android 文档中有关mimetype
属性的此信息:
android:mimeType - MIME 媒体类型,例如 image/jpeg 或 audio/mpeg4-generic。子类型可以是星号通配符,表示任何子类型匹配
但是,正如您所看到的vnd
,MIME 类型的前缀是“供应商前缀”,这意味着它不是官方的 IETF MIME 类型。因此,您需要为每个应用程序检查此类型。只是一些例子,我们在下面有什么。
笔记!为了设置默认应用程序,您需要先指定android.intent.action
。因为它是进程交互之间的主要标志,所以 Launcher(例如)不会有mimetype
,只有意图操作 android.intent.action.MAIN
,android.intent.action.SET_WALLPAPER
。
相机:
<data android:mimeType="vnd.android.cursor.dir/image" />
<data android:mimeType="vnd.android.cursor.dir/video" />
Run Code Online (Sandbox Code Playgroud)
图像/视频/音频:
<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" />
....
Run Code Online (Sandbox Code Playgroud)
联系人:
<data android:mimeType="vnd.android.cursor.item/phone" />
<data android:mimeType="vnd.android.cursor.item/person" />
<data android:mimeType="vnd.android.cursor.dir/calls" />
Run Code Online (Sandbox Code Playgroud)
浏览器:
<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"/>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
822 次 |
最近记录: |