带方案和主机的Intent过滤器不起作用

时间:2011-05-21 23:56:23

标签: android

我有以下intent filter

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="content" android:host="my.company.name" />
</intent-filter>

但它与以下Intent

不符
Uri uri = new Uri.Builder().scheme("content").authority("my.company.name").appendPath("names").build()
uri = Uri.withAppendedPath(uri, id1);
uri = Uri.withAppendedPath(uri, "data");

startActivity(new Intent(Intent.ACTION_VIEW, uri));

为什么会这样?

1 个答案:

答案 0 :(得分:3)

可能您无法为content方案注册活动,因为内容提供商系统会使用该活动。

如果您的活动确实由内容提供商支持,请改为使用内容的MIME类型,例如:

<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />

如果这与您的other recent SO question有关,您可能希望遵循回答该问题的Google员工的建议。 Here is a sample project演示了这种技巧,特别是清单中的第三个<intent-filter>