[英]Using implicit intent to launch activity?
我在使用隱式意圖在應用程序內啟動活動時遇到問題。
我創建了活動RecordList(列出所有專輯),RecordEditor(用於添加/編輯唱片曲目)和TrackEditor。 當用戶從RecordList中選擇新建或編輯時,我設法使RecordEditor啟動。 當我嘗試將新軌道添加到記錄中時(啟動TrackEditor活動),會出現問題。
這是我在清單中定義活動的方式:
記錄清單
<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>
記錄編輯器
<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>
軌道編輯器
<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>
這是我嘗試向Record中添加新曲目時不斷得到的例外:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.INSERT dat=content://com.example.provider.Track/tracks }
我以NotePad示例為基礎,但是我無法弄清楚我做錯了什么。 任何幫助,將不勝感激。 :)
目前尚不清楚您認為從這些“隱式意圖”中獲得了什么。
話雖如此,您的問題出在您的內容提供商身上。 這並不表示content://com.example.provider.Track/tracks
的MIME類型是您支持INSERT
操作的那些類型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.