我无法让我的应用程序响应content
过滤器方案。
我有一个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:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.riley"
android:scheme="content" />
</intent-filter>
但是,这不会从我的 gmail 中打开 .riley 文件。如果我删除该方案,如下所示:
<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:host="*"
android:mimeType="*/*"
android:pathPattern=".*\\.riley" />
</intent-filter>
这现在将从我的 gmail 打开文件。我想它一定不是来自content
计划,那么。所以我像这样记录了我的意图:
System.out.println("Intent\nScheme: " + intent.getScheme() + "\nAction: " + intent.getAction() + "\nFlags: " + intent.getFlags() + "\nPackage: " + intent.getPackage() + "\nMIME: " + intent.getType() + "\nData: " + intent.getData());
System.out.println("Intent\nScheme: " + intentUri.getScheme() + "\nPath: " + intentUri.getPath() + "\nHost: " + intentUri.getHost() + "\nTo String: " + intentUri.toString());
我的日志是这样的:
03-26 11:17:44.123: I/System.out(8796): Intent
03-26 11:17:44.123: I/System.out(8796): Scheme: content
03-26 11:17:44.123: I/System.out(8796): Action: android.intent.action.VIEW
03-26 11:17:44.123: I/System.out(8796): Flags: 50855937
03-26 11:17:44.123: I/System.out(8796): Package: null
03-26 11:17:44.123: I/System.out(8796): MIME: application/vnd.riley
03-26 11:17:44.123: I/System.out(8796): Data: content://gmail-ls/emailaddress@gmail.com/messages/5277/attachments/0.1.7/BEST/false
03-26 11:17:44.133: I/System.out(8796): Intent
03-26 11:17:44.133: I/System.out(8796): Scheme: content
03-26 11:17:44.133: I/System.out(8796): Path: /emailaddress@gmail.com/messages/5277/attachments/0.1.7/BEST/false
03-26 11:17:44.133: I/System.out(8796): Host: gmail-ls
03-26 11:17:44.133: I/System.out(8796): To String: content://gmail-ls/emailaddress@gmail.com/messages/5277/attachments/0.1.7/BEST/false
这让我很困惑,因为路径实际上并没有以“.riley”结尾,但是如果我将 MIME 类型设置为检查“.riley”,则intent-filter
停止工作。
为了正确打开它,我intent-filter
应该做什么,为什么我的第一个示例不起作用?