android developer tiny share-20160826

来源:互联网 发布:php怎么读 编辑:程序博客网 时间:2024/06/18 08:41

今天讲使用intent创建记事本。

New Note
Create a note

To create a new note, use the ACTION_CREATE_NOTE action and specify note details such as the subject and text using extras defined below.

Note: Apps must ask for confirmation from the user before completing the action.

Action

    ACTION_CREATE_NOTE
Data URI Scheme
    None
MIME Type
    PLAIN_TEXT_TYPE
    "*/*"
Extras
    EXTRA_NAME
        A string indicating the title or subject of the note.
    EXTRA_TEXT
        A string indicating the text of the note.
Example intent:

public void createNote(String subject, String text) {    Intent intent = new Intent(NoteIntents.ACTION_CREATE_NOTE)            .putExtra(NoteIntents.EXTRA_NAME, subject)            .putExtra(NoteIntents.EXTRA_TEXT, text);    if (intent.resolveActivity(getPackageManager()) != null) {        startActivity(intent);    }}

Example intent filter:

<activity ...>    <intent-filter>        <action android:name="com.google.android.gms.actions.CREATE_NOTE" />        <category android:name="android.intent.category.DEFAULT" />        <data android:mimeType=”*/*”>    </intent-filter></activity>


0 0