2
我有一個問題,使用隱式意圖在我的應用程序中啓動活動。使用隱式意圖啓動活動?
我已經創建了活動RecordList(列出所有專輯),RecordEditor(用於添加/編輯記錄曲目)和TrackEditor。我設法讓RecordEditor在用戶從RecordList中選擇新的或編輯時啓動。當我嘗試向記錄添加新軌道(啓動TrackEditor活動)時,會發生問題。
這裏是我如何在清單中定義的活動:
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>
這裏是我不斷收到嘗試新曲目添加到記錄時除外:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT dat=content://com.example.provider.Track/tracks }
我用記事本示例作爲這個基地,但我無法弄清楚我做錯了什麼。任何幫助,將不勝感激。 :)
我只是想熟悉創建自定義內容提供者並讓他們使用隱式意圖。我將檢查我的MIME類型並嘗試找出問題所在。謝謝你的幫助。 – svidnas 2011-01-28 07:21:34