简体   繁体   English

使用隐式意图启动活动?

[英]Using implicit intent to launch activity?

I have a problem using implicit intent to launch activity within my application. 我在使用隐式意图在应用程序内启动活动时遇到问题。

I have created activities RecordList (lists all the albums), RecordEditor (used to add/edit tracks of record) and TrackEditor. 我创建了活动RecordList(列出所有专辑),RecordEditor(用于添加/编辑唱片曲目)和TrackEditor。 I've managed to get the RecordEditor to launch when user selects new or edit from the RecordList. 当用户从RecordList中选择新建或编辑时,我设法使RecordEditor启动。 Problem occurs when I try to add new track to the the record (launch the TrackEditor activity). 当我尝试将新轨道添加到记录中时(启动TrackEditor活动),会出现问题。

Here is how I have defined the activities in manifest: 这是我在清单中定义活动的方式:
RecordList 记录清单

<activity android:name="RecordList">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <action android:name="android.intent.action.EDIT" />
        <action android:name="android.intent.action.PICK" />
        <data android:mimeType="vnd.android.cursor.item/vnd.example.record" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.GET_CONTENT" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="vnd.android.cursor.item/vnd.example.record" />
    </intent-filter>
</activity>

RecordEditor 记录编辑器

<intent-filter>
    <action android:name="android.intent.action.GET_CONTENT" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/vnd.example.track" />
</intent-filter>

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.EDIT" />
    <action android:name="com.example.records.action.EDIT_RECORD" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/vnd.example.record" />
</intent-filter>

<intent-filter>
    <action android:name="android.intent.action.INSERT" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.dir/vnd.example.record" />
</intent-filter>

TrackEditor 轨道编辑器

<activity android:name="TrackEditor">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <action android:name="android.intent.action.EDIT" />
        <action android:name="com.example.records.action.EDIT_TRACK" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="vnd.android.cursor.item/vnd.example.track" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.INSERT" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="vnd.android.cursor.dir/vnd.example.track" />
    </intent-filter>
</activity>

And here is the exception I keep getting when trying to add new track to Record: 这是我尝试向Record中添加新曲目时不断得到的例外:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT dat=content://com.example.provider.Track/tracks }

I've used the NotePad example as base for this but I am unable to figure out where I am doing wrong. 我以NotePad示例为基础,但是我无法弄清楚我做错了什么。 Any help would be appreciated. 任何帮助,将不胜感激。 :) :)

It is unclear what you think you are gaining from these "implicit Intents". 目前尚不清楚您认为从这些“隐式意图”中获得了什么。

That being said, your problem is with your content provider. 话虽如此,您的问题出在您的内容提供商身上。 It is not indicating that the MIME type for content://com.example.provider.Track/tracks is any of those for which you support the INSERT action. 这并不表示content://com.example.provider.Track/tracks的MIME类型是您支持INSERT操作的那些类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM