Android 我如何使我的应用程序对隐式打开PDF文件的意图可见?
我想创建一个简单的应用程序,可以查看PDF文件 为了测试我是否已删除emulator上的默认PDF文件查看器,并且当我想要打开PDF文件时,emulator会说Android 我如何使我的应用程序对隐式打开PDF文件的意图可见?,android,android-intent,android-manifest,Android,Android Intent,Android Manifest,我想创建一个简单的应用程序,可以查看PDF文件 为了测试我是否已删除emulator上的默认PDF文件查看器,并且当我想要打开PDF文件时,emulator会说无法打开该文件 如何使我的应用程序对该隐式意图可见,以便在单击该PDF文件时使用/显示该应用程序? 如果有,我需要在我的manifest.xml中添加什么配置?这对我有效,您没有指定sdk版本,而是检查它 <intent-filter> <action android:name="android.int
无法打开该文件
如何使我的应用程序对该隐式意图可见,以便在单击该PDF文件时使用/显示该应用程序?
如果有,我需要在我的manifest.xml
中添加什么
配置?这对我有效,您没有指定sdk版本,而是检查它
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="*/*" android:host="*" android:pathPattern=".*.csv" />
</intent-filter>
@请参见
在对视图进行了调整后,javdromero的方法对我很有效
1.指定PDF mime类型
PDF文件的mime类型为application/PDF
,因此我们必须使用:
android:mimeType="application/pdf"
可以忽略android:host
属性,因为我们没有从web获取任何内容,也没有指定android:scheme
属性。这同样适用于android:pathPattern
属性。请参阅
元素的
这会给我们留下一条错误消息缺少URL
,文本为红色
2.忽略丢失的URL错误
缺少URL
错误涉及整个
元素,因为我们应该在那里指定android:scheme
属性。
但是我们不使用任何方案,因此我们导入tools
名称空间并指定tools:ignore
属性:
tools:ignore="AppLinkError"
这就给我们留下了以下
元素配置:
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/pdf" />
</intent-filter>
告诉我这样做时缺少URL
错误。我指定了mimeType=“application/pdf”
和pathPattern=“.*.pdf”
。您可以使用