Android 意图解析-包含来自ContentProvider的数据的隐式意图
我患有意图解决机制 我有一个内容提供商:Android 意图解析-包含来自ContentProvider的数据的隐式意图,android,android-intent,android-contentprovider,Android,Android Intent,Android Contentprovider,我患有意图解决机制 我有一个内容提供商: <provider android:authorities="com.company.app" android:name=".content.MyProvider" android:exported="false" /> 我希望意图解析为DetailedFlowActivity,但它没有告诉我没有找到合适的Activity来处理此类意图:其中action=com.company.app.EDIT\u CATEGORY and data
<provider
android:authorities="com.company.app"
android:name=".content.MyProvider"
android:exported="false" />
我希望意图解析为DetailedFlowActivity
,但它没有告诉我没有找到合适的Activity
来处理此类意图:其中action=com.company.app.EDIT\u CATEGORY and data=content://com.company.app/categories/123
我当然可以使用显式意图,因为这些东西发生在我的应用程序中,但我更愿意使用漂亮的RESTful方法:)
感谢您的帮助。好的,现在我明白了。Luksprog的评论迫使我再次阅读,并更加关注URI数据匹配部分 首先指定默认类别,因为意图是隐含的。这是必要的,我错过了这件事 第二个,尽管它说: 包含URI但没有MIME类型(既不显式也不显式)的意图 可从URI推断)仅当其URI与 筛选器的URI格式,并且筛选器同样不指定MIME 类型 我发现在我的
ContentProvider
I的情况下,我需要为意图过滤器指定MIME类型。并通过操作将my intent筛选器拆分为两个筛选器:
<intent-filter>
<action android:name="com.company.app.EDIT_CATEGORY" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="content"
android:host="com.trustydroid.xpense"
android:mimeType="vnd.android.cursor.item/vdn.categories"
/>
</intent-filter>
。。另一个也一样
希望这能有所帮助。这里有一条说明,你应该读。@Luksprog,谢谢你强迫我重读这份文件:)
Intent intent = new Intent(DetailedFlowActivity.ACTION_EDIT_CATEGORY);
intent.setData(
Uri.withAppendedPath(CategoryItemContract.CONTENT_URI,
String.valueOf(categoryId)));
startActivity(intent);
<intent-filter>
<action android:name="com.company.app.EDIT_CATEGORY" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="content"
android:host="com.trustydroid.xpense"
android:mimeType="vnd.android.cursor.item/vdn.categories"
/>
</intent-filter>