我想從http://code.google.com/p/iosched/source/checkout瞭解一些事情。我想看看他們是如何實現他們在I/O上討論的UI模式的。意向開始於Android的幫助
在HomeActivity他們使用此代碼來火了NotesActivity:
/* Launch list of notes user has taken*/
public void onNotesClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Notes.CONTENT_URI));
}
票據類是ScheduleContract類,它看起來像:
public static class Notes implements NotesColumns, BaseColumns {
public static final Uri CONTENT_URI =
BASE_CONTENT_URI.buildUpon().appendPath(PATH_NOTES).build();
public static final Uri CONTENT_EXPORT_URI =
CONTENT_URI.buildUpon().appendPath(PATH_EXPORT).build();
/** {@link Sessions#SESSION_ID} that this note references. */
public static final String SESSION_ID = "session_id";
/** Default "ORDER BY" clause. */
public static final String DEFAULT_SORT = NotesColumns.NOTE_TIME + " DESC";
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/vnd.iosched.note";
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/vnd.iosched.note";
public static Uri buildNoteUri(long noteId) {
return ContentUris.withAppendedId(CONTENT_URI, noteId);
}
public static long getNoteId(Uri uri) {
return ContentUris.parseId(uri);
}
}
我不能看到這段代碼究竟做了什麼,以及它是如何結束的,並且啓動了NotesActivity並加載了筆記。我也不知道d是什麼URI用作新的第二個參數:
意圖(Intent.ACTION_VIEW,Notes.CONTENT_URI)。
我在Google上搜索瞭解釋,但沒有找到簡單的例子。我猜Notes類是用來指向和格式化數據(註釋),然後以某種方式NotesActivity開始,但不明白如何。
謝謝,我使用連接意向的基礎知識。在我上面的例子中,他們使用內容提供者,URI指向存儲在該提供者中的註釋。 – 2010-11-15 13:44:56