2011-05-21 66 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