gpt4 book ai didi

android - 如何指定一个 Intent 过滤器来识别 jpg 文件,而不是 Android 中的 jpeg?

转载 作者:行者123 更新时间:2023-11-30 03:06:09 24 4
gpt4 key购买 nike

基本上,我希望我的应用能够打开JPGjpg 文件,但不能打开文件扩展名为JPEG 或< em>jpeg。这是我的 Intent 过滤器,但它也接受 JPEGjpeg:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:mimeType="application/octet-stream" android:pathPattern=".*\\.jpg" />
<data android:scheme="file" android:mimeType="application/octet-stream" android:pathPattern=".*\\.jpg" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:pathPattern=".*\\.jpg" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:mimeType="application/octet-stream" android:pathPattern=".*\\.JPG" />
<data android:scheme="file" android:mimeType="application/octet-stream" android:pathPattern=".*\\.JPG" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:pathPattern=".*\\.JPG" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/jpg" android:pathPattern=".*\\.jpg"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/jpg" android:pathPattern=".*\\.JPG"/>
</intent-filter>

如何改进此 Intent 过滤器以仅处理特定的图像文件扩展名?

最佳答案

您正在捕获 JPEG 图像,因为您指定了 android:mimeTypeimage/jpg , JPEG 图像适合。从您的 <data> 中删除该标签元素并指定 android:pathPattern .

关于android - 如何指定一个 Intent 过滤器来识别 jpg 文件,而不是 Android 中的 jpeg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21788776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com