2011-05-21 64 views
3

我有一个下列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)); 

为什么会出现这种情况?

回答

3

您可能无法注册content方案的活动,就像内容提供商系统使用的那样。

如果您的活动确实是由内容提供商的支持,使用MIME类型的内容,而不是,如:

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

如果这涉及到你的other recent SO question,你不妨跟随谷歌的建议回答该问题的员工。 Here is a sample project展示了这种技术,特别是清单中的第三个<intent-filter>

+0

那么它是如何工作的显示与'ACTION_VIEW'和uri像'content:// contacts/people/1'的联系信息?另外,是的,这个问题是相关的,我也计划为'http'方案添加过滤器,但最初我想实现类似于联系人的使用模式。 – Fixpoint 2011-05-22 00:39:56

+0

忽视以前的评论:)看起来系统要求每个注册的内容提供者确定URI的MIME类型并隐含地将该信息添加到意图。所以,添加MIME类型真的解决了这个问题。谢谢! – Fixpoint 2011-05-22 00:45:48