我想从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