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

如何指定一个意图过滤器来识别jpg文件,而不是Android中的jpeg?,android,android-intent,mime-types,intentfilter,Android,Android Intent,Mime Types,Intentfilter,基本上,我希望我的应用程序能够打开JPG或JPG文件,但不能打开文件扩展名为JPEG或JPEG的文件。这是我的意图过滤器,但它也接受JPEG和JPEG: 如何改进此意图过滤器以仅处理特定的图像文件扩展名?您正在捕获JPEG图像,因为您指定了image/jpg的android:mimeType,这是适合JPEG图像的。从元素中删除该标记,只需指定android:pathPattern <intent-filter> <action android:name="andr

基本上,我希望我的应用程序能够打开JPG或JPG文件,但不能打开文件扩展名为JPEG或JPEG的文件。这是我的意图过滤器,但它也接受JPEG和JPEG:



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

您正在捕获JPEG图像,因为您指定了
image/jpg
android:mimeType
,这是适合JPEG图像的。从
元素中删除该标记,只需指定
android:pathPattern

<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>