Note Pad Example
- 노트 패드 예제는 사용자가 노트 리스트를 탐색하고 리스트내의 개별 아이템의 세부내용을 볼 수 있게 한다. 그리고 사용자는 리스트에 새로운 아이템을 추가할 수 있게 한다.
- Note Pad 어플은 각각 최소한 하나 이상의 인텐트 필터를 가진 세 개의 액티비티를 manifest 파일에 선언한다. 그것은 노트 데이터를 관리하는 콘텐트 프로바이더를 추가로 선언한다.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.notepad">
<application android:icon="@drawable/app_notes"
android:label="@string/app_name" >
<provider android:name="NotePadProvider"
android:authorities="com.google.provider.NotePad" />
<activity android:name="NotesList" android:label="@string/title_notes_list">
<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" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</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.google.note" />
</intent-filter>
</activity>
<activity android:name="NoteEditor"
android:theme="@android:style/Theme.Light"
android:label="@string/title_note" >
<intent-filter android:label="@string/resolve_edit">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="com.android.notepad.action.EDIT_NOTE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</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.google.note" />
</intent-filter>
</activity>
<activity android:name="TitleEditor"
android:label="@string/title_edit_title"
android:theme="@android:style/Theme.Dialog">
<intent-filter android:label="@string/resolve_title">
<action android:name="com.android.notepad.action.EDIT_TITLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.ALTERNATIVE" />
<category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
</application>
</manifest>
<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" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>
디렉토리를 탐색(VIEW), 편집(EDIT)하고 디렉토리내의 특정 노트를 선택(PICK)할 수 있게 한다.
데이터 엘러먼트의 mimeType 속성은 액션들이 수행할 데이터 종류를 지정한다.
이것은 액티비티가 노트패드 데이터(vnd.google.note)를 보유한 콘텐트 프로바이더로부터
0개 이상의 아이템들(vnd.android.cursor.dir)에 대해 Cursor를 얻을 수 있음을 보인다.
<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.google.note" />
</intent-filter>
| action : | android.intent.action.VIEW |
| data : | content://com.google.provider.NotePad/notes/ID |
| 액티비티로 하여금 ID로 지정된 노트의 내용을 표현하게 한다. | |
| action : | android.intent.action.INSERT |
| data : | content://com.google.provider.NotePad/notes |
| 액티비티가 새로운 빈 노트를 content://com.google.provider.NotePad/notes에 만들고 편집하게 한다. | |
<intent-filter android:label="@string/resolve_title">
<action android:name="com.android.notepad.action.EDIT_TITLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.ALTERNATIVE" />
<category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
ALTERNATIVE와 SELECTED_ALTERNATIVE는 옵션의 메뉴로 표현될 수 있는 액티비티를 지정한다.
| action: | com.android.notepad.action.EDIT_TITLE |
| data: | content://com.google.provider.NotePad/notes/ID |
| 노트 ID와 관련된 타이틀을 표시하고, 편집한다. | |