0
我試過以下關於Intents和Intent Filters的文章,希望將我的應用從顯式轉移到隱式意圖(似乎讓事情變得更簡單)。然而,我的Intents
從來沒有匹配,無論我多努力嘗試。相關信息如下:爲什麼我的意圖不匹配?
Intent in = new Intent(Intent.ACTION_VIEW, Provider.constantsUri);
//in.addCategory(Intent.CATEGORY_DEFAULT); is this required?
startActivity(in);
,並在我的清單:
<activity android:name="Equation" >
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<data android:scheme="content" android:host="com.espian.formulae.pro" android:path="const"></data>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
和constantsUri的定義:
public static Uri constantsUri = Uri.parse("content://com.espian.formulae.pro/const");
我也試過用Uri.Builder
形成Uri
,但沒有要麼運氣。有什麼明顯的我失蹤了嗎?
看來,如果我只有一個計劃和主機在數據(如你的例子)它的工作原理,但如果我把一個路徑(這是必需的),它不匹配?事情是,這個例外說沒有什麼與Uri解析的_exact相同的Uri_匹配。將嘗試使用數據類型 – 2011-03-29 21:16:43
您確定您的路徑正確嗎?我想如果你從你的例子中記錄constantsUri.getPath(),它實際上會顯示「/ const」。嘗試更改您的意圖過濾器以包含前導斜槓。 – mikerowehl 2011-03-29 21:34:10
您評論中概述的內容有效(即它需要前導斜線)謝謝:) – 2011-05-23 01:19:26