Intent-Filter无法正确响应内容

时间:2013-03-26 16:30:46

标签: android android-intent intentfilter

我无法让我的应用程序响应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应该怎样才能正确地打开这个?为什么我的第一个例子不起作用?

0 个答案:

没有答案