Intent.java分析

  代碼位於frameworks/base/core/java/anroid/Content/Intent.javahtml

Intent是對要進行操做的一種抽象描述。用action抽象操做,用data(android.net.Uri)抽象操做參數。java

除此以外,category用來描述action所屬的類別(添加action對應的component的額外屬性)來指導系相應的component如何被匹配與被處理,type用來指定data的MIME類型;component指定用來執行action的組件,若是指定了這個,其餘參數被忽略;extra用來給component相應方法附加額外的所需參數。node

 

先打成package android.content,並import這些類android

 1 17package android.content;
 2 18
 3 19import android.annotation.AnyRes;
 4 20import android.annotation.IntDef;
 5 21import android.annotation.SdkConstant;
 6 22import android.annotation.SdkConstant.SdkConstantType;
 7 23import android.annotation.SystemApi;
 8 24import android.content.pm.ActivityInfo;
 9 25import android.content.pm.ApplicationInfo;
10 26import android.content.pm.ComponentInfo;
11 27import android.content.pm.PackageManager;
12 28import android.content.pm.ResolveInfo;
13 29import android.content.res.Resources;
14 30import android.content.res.TypedArray;
15 31import android.graphics.Rect;
16 32import android.net.Uri;
17 33import android.os.Build;
18 34import android.os.Bundle;
19 35import android.os.IBinder;
20 36import android.os.Parcel;
21 37import android.os.Parcelable;
22 38import android.os.Process;
23 39import android.os.ResultReceiver;
24 40import android.os.ShellCommand;
25 41import android.os.StrictMode;
26 42import android.os.UserHandle;
27 43import android.provider.DocumentsContract;
28 44import android.provider.DocumentsProvider;
29 45import android.provider.MediaStore;
30 46import android.provider.OpenableColumns;
31 47import android.util.ArraySet;
32 48import android.util.AttributeSet;
33 49import android.util.Log;
34 50import com.android.internal.util.XmlUtils;
35 51import org.xmlpull.v1.XmlPullParser;
36 52import org.xmlpull.v1.XmlPullParserException;
37 53import org.xmlpull.v1.XmlSerializer;
38 54
39 55import java.io.IOException;
40 56import java.io.PrintWriter;
41 57import java.io.Serializable;
42 58import java.lang.annotation.Retention;
43 59import java.lang.annotation.RetentionPolicy;
44 60import java.net.URISyntaxException;
45 61import java.util.ArrayList;
46 62import java.util.HashSet;
47 63import java.util.List;
48 64import java.util.Locale;
49 65import java.util.Objects;
50 66import java.util.Set;
51 67
52 68import static android.content.ContentProvider.maybeAddUserId;

這個類實現了Parcelable和Cloneable接口ios

1 619public class Intent implements Parcelable, Cloneable {

定義了的attr字符串有action,category,type,component,data,flagsgit

1 620    private static final String ATTR_ACTION = "action";
2 622    private static final String ATTR_CATEGORY = "category";
3 624    private static final String ATTR_TYPE = "type";
4 625    private static final String ATTR_COMPONENT = "component";
5 626    private static final String ATTR_DATA = "data";
6 627    private static final String ATTR_FLAGS = "flags";

tag字符串有categories,extraweb

1 621    private static final String TAG_CATEGORIES = "categories";
2 623    private static final String TAG_EXTRA = "extra";

 

下面是字符串常量docker

ACTION_MAIN啓動一個activity爲main入口shell

 1 629    // ---------------------------------------------------------------------
 2 630    // ---------------------------------------------------------------------
 3 631    // Standard intent activity actions (see action variable).
 4 632
 5 633    /**
 6 634     *  Activity Action: Start as a main entry point, does not expect to
 7 635     *  receive data.
 8 636     *  <p>Input: nothing
 9 637     *  <p>Output: nothing
10 638     */
11 639    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
12 640    public static final String ACTION_MAIN = "android.intent.action.MAIN";

ACTION_VIEW啓動activity用來顯示數據數據庫

 1 642    /**
 2 643     * Activity Action: Display the data to the user.  This is the most common
 3 644     * action performed on data -- it is the generic action you can use on
 4 645     * a piece of data to get the most reasonable thing to occur.  For example,
 5 646     * when used on a contacts entry it will view the entry; when used on a
 6 647     * mailto: URI it will bring up a compose window filled with the information
 7 648     * supplied by the URI; when used with a tel: URI it will invoke the
 8 649     * dialer.
 9 650     * <p>Input: {@link #getData} is URI from which to retrieve data.
10 651     * <p>Output: nothing.
11 652     */
12 653    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
13 654    public static final String ACTION_VIEW = "android.intent.action.VIEW";

ACTION_DEFAULT和ACTION_VIEW同樣

1 656    /**
2 657     * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
3 658     * performed on a piece of data.
4 659     */
5 660    public static final String ACTION_DEFAULT = ACTION_VIEW;

ACTION_QUICK_VIEW用來快速瀏覽數據

 1 662    /**
 2 663     * Activity Action: Quick view the data. Launches a quick viewer for
 3 664     * a URI or a list of URIs.
 4 665     * <p>Activities handling this intent action should handle the vast majority of
 5 666     * MIME types rather than only specific ones.
 6 667     * <p>Input: {@link #getData} is a mandatory content URI of the item to
 7 668     * preview. {@link #getClipData} contains an optional list of content URIs
 8 669     * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
 9 670     * optional index of the URI in the clip data to show first.
10 671     * <p>Output: nothing.
11 672     */
12 673    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
13 674    public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";

ACTION_ATTACH_DATA用來附加數據到某個component上

 1 676    /**
 2 677     * Used to indicate that some piece of data should be attached to some other
 3 678     * place.  For example, image data could be attached to a contact.  It is up
 4 679     * to the recipient to decide where the data should be attached; the intent
 5 680     * does not specify the ultimate destination.
 6 681     * <p>Input: {@link #getData} is URI of data to be attached.
 7 682     * <p>Output: nothing.
 8 683     */
 9 684    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
10 685    public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
11 686

ACTION_EDIT用來編輯數據

1 687    /**
2 688     * Activity Action: Provide explicit editable access to the given data.
3 689     * <p>Input: {@link #getData} is URI of data to be edited.
4 690     * <p>Output: nothing.
5 691     */
6 692    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 693    public static final String ACTION_EDIT = "android.intent.action.EDIT";

ACTION_INSERT_OR_EDIT用來插入或者編輯數據

 1 695    /**
 2 696     * Activity Action: Pick an existing item, or insert a new item, and then edit it.
 3 697     * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
 4 698     * The extras can contain type specific data to pass through to the editing/creating
 5 699     * activity.
 6 700     * <p>Output: The URI of the item that was picked.  This must be a content:
 7 701     * URI so that any receiver can access it.
 8 702     */
 9 703    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
10 704    public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";

ACTION_PICK用來從一個目錄裏選數據

1 706    /**
2 707     * Activity Action: Pick an item from the data, returning what was selected.
3 708     * <p>Input: {@link #getData} is URI containing a directory of data
4 709     * (vnd.android.cursor.dir/*) from which to pick an item.
5 710     * <p>Output: The URI of the item that was picked.
6 711     */
7 712    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
8 713    public static final String ACTION_PICK = "android.intent.action.PICK";

ACTION_CREATE_SHORTCUT建立快捷方式

 1 715    /**
 2 716     * Activity Action: Creates a shortcut.
 3 717     * <p>Input: Nothing.</p>
 4 718     * <p>Output: An Intent representing the shortcut. The intent must contain three
 5 719     * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
 6 720     * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
 7 721     * (value: ShortcutIconResource).</p>
 8 722     *
 9 723     * @see #EXTRA_SHORTCUT_INTENT
10 724     * @see #EXTRA_SHORTCUT_NAME
11 725     * @see #EXTRA_SHORTCUT_ICON
12 726     * @see #EXTRA_SHORTCUT_ICON_RESOURCE
13 727     * @see android.content.Intent.ShortcutIconResource
14 728     */
15 729    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
16 730    public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";

下面的爲ACTION_CREATE_SHORTCUT相關的shortcut extra配置,用來配置shortcut Intent的名字,shortcut的名字資源,圖標資源

 1 732    /**
 2 733     * The name of the extra used to define the Intent of a shortcut.
 3 734     *
 4 735     * @see #ACTION_CREATE_SHORTCUT
 5 736     */
 6 737    public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
 7 738    /**
 8 739     * The name of the extra used to define the name of a shortcut.
 9 740     *
10 741     * @see #ACTION_CREATE_SHORTCUT
11 742     */
12 743    public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
13 744    /**
14 745     * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
15 746     *
16 747     * @see #ACTION_CREATE_SHORTCUT
17 748     */
18 749    public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
19 750    /**
20 751     * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
21 752     *
22 753     * @see #ACTION_CREATE_SHORTCUT
23 754     * @see android.content.Intent.ShortcutIconResource
24 755     */
25 756    public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
26 757            "android.intent.extra.shortcut.ICON_RESOURCE";

ACTION_APPLICATION_PREFERENCES調整app的preference

1 759    /**
2 760     * An activity that provides a user interface for adjusting application preferences.
3 761     * Optional but recommended settings for all applications which have settings.
4 762     */
5 763    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
6 764    public static final String ACTION_APPLICATION_PREFERENCES
7 765            = "android.intent.action.APPLICATION_PREFERENCES";

ACTION_SHOW_APP_INFO顯示app info

 1 767    /**
 2 768     * Activity Action: Launch an activity showing the app information.
 3 769     * For applications which install other applications (such as app stores), it is recommended
 4 770     * to handle this action for providing the app information to the user.
 5 771     *
 6 772     * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
 7 773     * to be displayed.
 8 774     * <p>Output: Nothing.
 9 775     */
10 776    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
11 777    public static final String ACTION_SHOW_APP_INFO
12 778            = "android.intent.action.SHOW_APP_INFO";
13 779

內部類ShortcutIconResource封裝了shortcut圖標相關的package名字和icon resource id。實現了Parcelabel接口,能夠經過Parcel來建立。也能夠經過Context來建立

 1 780    /**
 2 781     * Represents a shortcut/live folder icon resource.
 3 782     *
 4 783     * @see Intent#ACTION_CREATE_SHORTCUT
 5 784     * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
 6 785     * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
 7 786     * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
 8 787     */
 9 788    public static class ShortcutIconResource implements Parcelable {
10 789        /**
11 790         * The package name of the application containing the icon.
12 791         */
13 792        public String packageName;
14 793
15 794        /**
16 795         * The resource name of the icon, including package, name and type.
17 796         */
18 797        public String resourceName;
19 798
20 799        /**
21 800         * Creates a new ShortcutIconResource for the specified context and resource
22 801         * identifier.
23 802         *
24 803         * @param context The context of the application.
25 804         * @param resourceId The resource identifier for the icon.
26 805         * @return A new ShortcutIconResource with the specified's context package name
27 806         *         and icon resource identifier.``
28 807         */
29 808        public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
30 809            ShortcutIconResource icon = new ShortcutIconResource();
31 810            icon.packageName = context.getPackageName();
32 811            icon.resourceName = context.getResources().getResourceName(resourceId);
33 812            return icon;
34 813        }
35 814
36 815        /**
37 816         * Used to read a ShortcutIconResource from a Parcel.
38 817         */
39 818        public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
40 819            new Parcelable.Creator<ShortcutIconResource>() {
41 820
42 821                public ShortcutIconResource createFromParcel(Parcel source) {
43 822                    ShortcutIconResource icon = new ShortcutIconResource();
44 823                    icon.packageName = source.readString();
45 824                    icon.resourceName = source.readString();
46 825                    return icon;
47 826                }
48 827
49 828                public ShortcutIconResource[] newArray(int size) {
50 829                    return new ShortcutIconResource[size];
51 830                }
52 831            };
53 832
54 833        /**
55 834         * No special parcel contents.
56 835         */
57 836        public int describeContents() {
58 837            return 0;
59 838        }
60 839
61 840        public void writeToParcel(Parcel dest, int flags) {
62 841            dest.writeString(packageName);
63 842            dest.writeString(resourceName);
64 843        }
65 844
66 845        @Override
67 846        public String toString() {
68 847            return resourceName;
69 848        }
70 849    }
71 850

ACTION_CHOOSER用來選擇合適的Activity來作動做,而且能夠本身配置標題

 1 851    /**
 2 852     * Activity Action: Display an activity chooser, allowing the user to pick
 3 853     * what they want to before proceeding.  This can be used as an alternative
 4 854     * to the standard activity picker that is displayed by the system when
 5 855     * you try to start an activity with multiple possible matches, with these
 6 856     * differences in behavior:
 7 857     * <ul>
 8 858     * <li>You can specify the title that will appear in the activity chooser.
 9 859     * <li>The user does not have the option to make one of the matching
10 860     * activities a preferred activity, and all possible activities will
11 861     * always be shown even if one of them is currently marked as the
12 862     * preferred activity.
13 863     * </ul>
14 864     * <p>
15 865     * This action should be used when the user will naturally expect to
16 866     * select an activity in order to proceed.  An example if when not to use
17 867     * it is when the user clicks on a "mailto:" link.  They would naturally
18 868     * expect to go directly to their mail app, so startActivity() should be
19 869     * called directly: it will
20 870     * either launch the current preferred app, or put up a dialog allowing the
21 871     * user to pick an app to use and optionally marking that as preferred.
22 872     * <p>
23 873     * In contrast, if the user is selecting a menu item to send a picture
24 874     * they are viewing to someone else, there are many different things they
25 875     * may want to do at this point: send it through e-mail, upload it to a
26 876     * web service, etc.  In this case the CHOOSER action should be used, to
27 877     * always present to the user a list of the things they can do, with a
28 878     * nice title given by the caller such as "Send this photo with:".
29 879     * <p>
30 880     * If you need to grant URI permissions through a chooser, you must specify
31 881     * the permissions to be granted on the ACTION_CHOOSER Intent
32 882     * <em>in addition</em> to the EXTRA_INTENT inside.  This means using
33 883     * {@link #setClipData} to specify the URIs to be granted as well as
34 884     * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
35 885     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
36 886     * <p>
37 887     * As a convenience, an Intent of this form can be created with the
38 888     * {@link #createChooser} function.
39 889     * <p>
40 890     * Input: No data should be specified.  get*Extra must have
41 891     * a {@link #EXTRA_INTENT} field containing the Intent being executed,
42 892     * and can optionally have a {@link #EXTRA_TITLE} field containing the
43 893     * title text to display in the chooser.
44 894     * <p>
45 895     * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
46 896     */
47 897    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
48 898    public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
49 899

createChooser是建立ACTION_CHOOSE Intent的快捷函數

 1 900    /**
 2 901     * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
 3 902     *
 4 903     * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
 5 904     * target intent, also optionally supplying a title.  If the target
 6 905     * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
 7 906     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
 8 907     * set in the returned chooser intent, with its ClipData set appropriately:
 9 908     * either a direct reflection of {@link #getClipData()} if that is non-null,
10 909     * or a new ClipData built from {@link #getData()}.
11 910     *
12 911     * @param target The Intent that the user will be selecting an activity
13 912     * to perform.
14 913     * @param title Optional title that will be displayed in the chooser.
15 914     * @return Return a new Intent object that you can hand to
16 915     * {@link Context#startActivity(Intent) Context.startActivity()} and
17 916     * related methods.
18 917     */
19 918    public static Intent createChooser(Intent target, CharSequence title) {
20 919        return createChooser(target, title, null);
21 920    }

createChooser還能夠帶個IntentSender回調參數,用來記住用戶的選擇

能夠看到new個新的Intent包含舊的Intent的內容,而且若是要是有相應flag而且ClipData和getData有不爲Null的,就建立ClipData

 1 922    /**
 2 923     * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
 3 924     *
 4 925     * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
 5 926     * target intent, also optionally supplying a title.  If the target
 6 927     * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
 7 928     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
 8 929     * set in the returned chooser intent, with its ClipData set appropriately:
 9 930     * either a direct reflection of {@link #getClipData()} if that is non-null,
10 931     * or a new ClipData built from {@link #getData()}.</p>
11 932     *
12 933     * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
13 934     * when the user makes a choice. This can be useful if the calling application wants
14 935     * to remember the last chosen target and surface it as a more prominent or one-touch
15 936     * affordance elsewhere in the UI for next time.</p>
16 937     *
17 938     * @param target The Intent that the user will be selecting an activity
18 939     * to perform.
19 940     * @param title Optional title that will be displayed in the chooser.
20 941     * @param sender Optional IntentSender to be called when a choice is made.
21 942     * @return Return a new Intent object that you can hand to
22 943     * {@link Context#startActivity(Intent) Context.startActivity()} and
23 944     * related methods.
24 945     */
25 946    public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
26 947        Intent intent = new Intent(ACTION_CHOOSER);
27 948        intent.putExtra(EXTRA_INTENT, target);
28 949        if (title != null) {
29 950            intent.putExtra(EXTRA_TITLE, title);
30 951        }
31 952
32 953        if (sender != null) {
33 954            intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
34 955        }
35 956
36 957        // Migrate any clip data and flags from target.
37 958        int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
38 959                | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
39 960                | FLAG_GRANT_PREFIX_URI_PERMISSION);
40 961        if (permFlags != 0) {
41 962            ClipData targetClipData = target.getClipData();
42 963            if (targetClipData == null && target.getData() != null) {
43 964                ClipData.Item item = new ClipData.Item(target.getData());
44 965                String[] mimeTypes;
45 966                if (target.getType() != null) {
46 967                    mimeTypes = new String[] { target.getType() };
47 968                } else {
48 969                    mimeTypes = new String[] { };
49 970                }
50 971                targetClipData = new ClipData(null, mimeTypes, item);
51 972            }
52 973            if (targetClipData != null) {
53 974                intent.setClipData(targetClipData);
54 975                intent.addFlags(permFlags);
55 976            }
56 977        }
57 978
58 979        return intent;
59 980    }

ACTION_GET_CONTENT獲取相應的數據的內容,提供的不是具體的URI,而是數據類型。

 1 982    /**
 2 983     * Activity Action: Allow the user to select a particular kind of data and
 3 984     * return it.  This is different than {@link #ACTION_PICK} in that here we
 4 985     * just say what kind of data is desired, not a URI of existing data from
 5 986     * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
 6 987     * create the data as it runs (for example taking a picture or recording a
 7 988     * sound), let them browse over the web and download the desired data,
 8 989     * etc.
 9 990     * <p>
10 991     * There are two main ways to use this action: if you want a specific kind
11 992     * of data, such as a person contact, you set the MIME type to the kind of
12 993     * data you want and launch it with {@link Context#startActivity(Intent)}.
13 994     * The system will then launch the best application to select that kind
14 995     * of data for you.
15 996     * <p>
16 997     * You may also be interested in any of a set of types of content the user
17 998     * can pick.  For example, an e-mail application that wants to allow the
18 999     * user to add an attachment to an e-mail message can use this action to
19 1000     * bring up a list of all of the types of content the user can attach.
20 1001     * <p>
21 1002     * In this case, you should wrap the GET_CONTENT intent with a chooser
22 1003     * (through {@link #createChooser}), which will give the proper interface
23 1004     * for the user to pick how to send your data and allow you to specify
24 1005     * a prompt indicating what they are doing.  You will usually specify a
25 1006     * broad MIME type (such as image/* or {@literal *}/*), resulting in a
26 1007     * broad range of content types the user can select from.
27 1008     * <p>
28 1009     * When using such a broad GET_CONTENT action, it is often desirable to
29 1010     * only pick from data that can be represented as a stream.  This is
30 1011     * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
31 1012     * <p>
32 1013     * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
33 1014     * the launched content chooser only returns results representing data that
34 1015     * is locally available on the device.  For example, if this extra is set
35 1016     * to true then an image picker should not show any pictures that are available
36 1017     * from a remote server but not already on the local device (thus requiring
37 1018     * they be downloaded when opened).
38 1019     * <p>
39 1020     * If the caller can handle multiple returned items (the user performing
40 1021     * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
41 1022     * to indicate this.
42 1023     * <p>
43 1024     * Input: {@link #getType} is the desired MIME type to retrieve.  Note
44 1025     * that no URI is supplied in the intent, as there are no constraints on
45 1026     * where the returned data originally comes from.  You may also include the
46 1027     * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
47 1028     * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
48 1029     * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
49 1030     * allow the user to select multiple items.
50 1031     * <p>
51 1032     * Output: The URI of the item that was picked.  This must be a content:
52 1033     * URI so that any receiver can access it.
53 1034     */
54 1035    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
55 1036    public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";

 ACTION_DIAL出現一個撥號界面

 1 1037    /**
 2 1038     * Activity Action: Dial a number as specified by the data.  This shows a
 3 1039     * UI with the number being dialed, allowing the user to explicitly
 4 1040     * initiate the call.
 5 1041     * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
 6 1042     * is URI of a phone number to be dialed or a tel: URI of an explicit phone
 7 1043     * number.
 8 1044     * <p>Output: nothing.
 9 1045     */
10 1046    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
11 1047    public static final String ACTION_DIAL = "android.intent.action.DIAL";

 ACTION_CALL直接撥打電話

 1 1048    /**
 2 1049     * Activity Action: Perform a call to someone specified by the data.
 3 1050     * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
 4 1051     * is URI of a phone number to be dialed or a tel: URI of an explicit phone
 5 1052     * number.
 6 1053     * <p>Output: nothing.
 7 1054     *
 8 1055     * <p>Note: there will be restrictions on which applications can initiate a
 9 1056     * call; most applications should use the {@link #ACTION_DIAL}.
10 1057     * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
11 1058     * numbers.  Applications can <strong>dial</strong> emergency numbers using
12 1059     * {@link #ACTION_DIAL}, however.
13 1060     *
14 1061     * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
15 1062     * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
16 1063     * permission which is not granted, then attempting to use this action will
17 1064     * result in a {@link java.lang.SecurityException}.
18 1065     */
19 1066    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
20 1067    public static final String ACTION_CALL = "android.intent.action.CALL";

ACTION_CALL_EMERGENCY直接撥打緊急電話

 1 1068    /**
 2 1069     * Activity Action: Perform a call to an emergency number specified by the
 3 1070     * data.
 4 1071     * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
 5 1072     * tel: URI of an explicit phone number.
 6 1073     * <p>Output: nothing.
 7 1074     * @hide
 8 1075     */
 9 1076    public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
10 1077    /**

ACTION_CALL_PRIVILEGED撥打任意類型的電話

1 1077    /**
2 1078     * Activity action: Perform a call to any number (emergency or not)
3 1079     * specified by the data.
4 1080     * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
5 1081     * tel: URI of an explicit phone number.
6 1082     * <p>Output: nothing.
7 1083     * @hide
8 1084     */
9 1085    public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";

ACTION_SIM_ACTIVATION_REQUEST請求激活sim卡

 1 1086    /**
 2 1087     * Activity action: Activate the current SIM card.  If SIM cards do not require activation,
 3 1088     * sending this intent is a no-op.
 4 1089     * <p>Input: No data should be specified.  get*Extra may have an optional
 5 1090     * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
 6 1091     * send the activation result.
 7 1092     * <p>Output: nothing.
 8 1093     * @hide
 9 1094     */
10 1095    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
11 1096    public static final String ACTION_SIM_ACTIVATION_REQUEST =
12 1097            "android.intent.action.SIM_ACTIVATION_REQUEST";

ACTION_SENDTO發送信息給其餘人

1 1098    /**
2 1099     * Activity Action: Send a message to someone specified by the data.
3 1100     * <p>Input: {@link #getData} is URI describing the target.
4 1101     * <p>Output: nothing.
5 1102     */
6 1103    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1104    public static final String ACTION_SENDTO = "android.intent.action.SENDTO";

ACTION_SEND發送數據

 1 1105    /**
 2 1106     * Activity Action: Deliver some data to someone else.  Who the data is
 3 1107     * being delivered to is not specified; it is up to the receiver of this
 4 1108     * action to ask the user where the data should be sent.
 5 1109     * <p>
 6 1110     * When launching a SEND intent, you should usually wrap it in a chooser
 7 1111     * (through {@link #createChooser}), which will give the proper interface
 8 1112     * for the user to pick how to send your data and allow you to specify
 9 1113     * a prompt indicating what they are doing.
10 1114     * <p>
11 1115     * Input: {@link #getType} is the MIME type of the data being sent.
12 1116     * get*Extra can have either a {@link #EXTRA_TEXT}
13 1117     * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
14 1118     * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
15 1119     * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
16 1120     * if the MIME type is unknown (this will only allow senders that can
17 1121     * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
18 1122     * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
19 1123     * your text with HTML formatting.
20 1124     * <p>
21 1125     * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
22 1126     * being sent can be supplied through {@link #setClipData(ClipData)}.  This
23 1127     * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
24 1128     * content: URIs and other advanced features of {@link ClipData}.  If
25 1129     * using this approach, you still must supply the same data through the
26 1130     * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
27 1131     * for compatibility with old applications.  If you don't set a ClipData,
28 1132     * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
29 1133     * <p>
30 1134     * Optional standard extras, which may be interpreted by some recipients as
31 1135     * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
32 1136     * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
33 1137     * <p>
34 1138     * Output: nothing.
35 1139     */
36 1140    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
37 1141    public static final String ACTION_SEND = "android.intent.action.SEND";

ACTION_SEND_MULTIPLE發送多個數據

 1 1142    /**
 2 1143     * Activity Action: Deliver multiple data to someone else.
 3 1144     * <p>
 4 1145     * Like {@link #ACTION_SEND}, except the data is multiple.
 5 1146     * <p>
 6 1147     * Input: {@link #getType} is the MIME type of the data being sent.
 7 1148     * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
 8 1149     * #EXTRA_STREAM} field, containing the data to be sent.  If using
 9 1150     * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
10 1151     * for clients to retrieve your text with HTML formatting.
11 1152     * <p>
12 1153     * Multiple types are supported, and receivers should handle mixed types
13 1154     * whenever possible. The right way for the receiver to check them is to
14 1155     * use the content resolver on each URI. The intent sender should try to
15 1156     * put the most concrete mime type in the intent type, but it can fall
16 1157     * back to {@literal <type>/*} or {@literal *}/* as needed.
17 1158     * <p>
18 1159     * e.g. if you are sending image/jpg and image/jpg, the intent's type can
19 1160     * be image/jpg, but if you are sending image/jpg and image/png, then the
20 1161     * intent's type should be image/*.
21 1162     * <p>
22 1163     * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
23 1164     * being sent can be supplied through {@link #setClipData(ClipData)}.  This
24 1165     * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
25 1166     * content: URIs and other advanced features of {@link ClipData}.  If
26 1167     * using this approach, you still must supply the same data through the
27 1168     * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
28 1169     * for compatibility with old applications.  If you don't set a ClipData,
29 1170     * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
30 1171     * <p>
31 1172     * Optional standard extras, which may be interpreted by some recipients as
32 1173     * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
33 1174     * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
34 1175     * <p>
35 1176     * Output: nothing.
36 1177     */
37 1178    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
38 1179    public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
39 1180    /**

ACTION_ANSWER用來接電話

1 1180    /**
2 1181     * Activity Action: Handle an incoming phone call.
3 1182     * <p>Input: nothing.
4 1183     * <p>Output: nothing.
5 1184     */
6 1185    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1186    public static final String ACTION_ANSWER = "android.intent.action.ANSWER";

ACTION_INSERT用來插入數據

1 1187    /**
2 1188     * Activity Action: Insert an empty item into the given container.
3 1189     * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
4 1190     * in which to place the data.
5 1191     * <p>Output: URI of the new data that was created.
6 1192     */
7 1193    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
8 1194    public static final String ACTION_INSERT = "android.intent.action.INSERT";

ACTION_PASTE從剪切板裏粘貼數據

1 1195    /**
2 1196     * Activity Action: Create a new item in the given container, initializing it
3 1197     * from the current contents of the clipboard.
4 1198     * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
5 1199     * in which to place the data.
6 1200     * <p>Output: URI of the new data that was created.
7 1201     */
8 1202    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
9 1203    public static final String ACTION_PASTE = "android.intent.action.PASTE";

ACTION_DELETE刪除數據

1 1204    /**
2 1205     * Activity Action: Delete the given data from its container.
3 1206     * <p>Input: {@link #getData} is URI of data to be deleted.
4 1207     * <p>Output: nothing.
5 1208     */
6 1209    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1210    public static final String ACTION_DELETE = "android.intent.action.DELETE";

ACTION_RUN運行相應數據

1 1211    /**
2 1212     * Activity Action: Run the data, whatever that means.
3 1213     * <p>Input: ?  (Note: this is currently specific to the test harness.)
4 1214     * <p>Output: nothing.
5 1215     */
6 1216    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1217    public static final String ACTION_RUN = "android.intent.action.RUN";

ACTION_SYNC同步數據

1 1218    /**
2 1219     * Activity Action: Perform a data synchronization.
3 1220     * <p>Input: ?
4 1221     * <p>Output: ?
5 1222     */
6 1223    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1224    public static final String ACTION_SYNC = "android.intent.action.SYNC";

ACTION_PICK_ACTIVITY選取符合相應Intent-filter的Activity類名

 1 1225    /**
 2 1226     * Activity Action: Pick an activity given an intent, returning the class
 3 1227     * selected.
 4 1228     * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
 5 1229     * used with {@link PackageManager#queryIntentActivities} to determine the
 6 1230     * set of activities from which to pick.
 7 1231     * <p>Output: Class name of the activity that was selected.
 8 1232     */
 9 1233    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
10 1234    public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";

ACTION_SEARCH用來搜索

 1 1235    /**
 2 1236     * Activity Action: Perform a search.
 3 1237     * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
 4 1238     * is the text to search for.  If empty, simply
 5 1239     * enter your search results Activity with the search UI activated.
 6 1240     * <p>Output: nothing.
 7 1241     */
 8 1242    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
 9 1243    public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
10 1244    /**

 ACTION_SYSTEM_TUTORIAL啓動系統定義的教程

1 1244    /**
2 1245     * Activity Action: Start the platform-defined tutorial
3 1246     * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
4 1247     * is the text to search for.  If empty, simply
5 1248     * enter your search results Activity with the search UI activated.
6 1249     * <p>Output: nothing.
7 1250     */
8 1251    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
9 1252    public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";

ACTION_WEB_SEARCH作網絡搜索

 1 1253    /**
 2 1254     * Activity Action: Perform a web search.
 3 1255     * <p>
 4 1256     * Input: {@link android.app.SearchManager#QUERY
 5 1257     * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
 6 1258     * a url starts with http or https, the site will be opened. If it is plain
 7 1259     * text, Google search will be applied.
 8 1260     * <p>
 9 1261     * Output: nothing.
10 1262     */
11 1263    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
12 1264    public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
13 1265

ACTION_ASSIST用來作輔助操做

 1 1266    /**
 2 1267     * Activity Action: Perform assist action.
 3 1268     * <p>
 4 1269     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
 5 1270     * additional optional contextual information about where the user was when they
 6 1271     * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
 7 1272     * information.
 8 1273     * Output: nothing.
 9 1274     */
10 1275    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
11 1276    public static final String ACTION_ASSIST = "android.intent.action.ASSIST";

ACTION_VOICE_ASSIST作語音輔助

 1 1278    /**
 2 1279     * Activity Action: Perform voice assist action.
 3 1280     * <p>
 4 1281     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
 5 1282     * additional optional contextual information about where the user was when they
 6 1283     * requested the voice assist.
 7 1284     * Output: nothing.
 8 1285     * @hide
 9 1286     */
10 1287    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
11 1288    public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";

EXTRA_ASSIST_PACKAGE爲正在輔助的前臺程序包名,EXTRA_ASSIST_UID爲正在輔助的前臺程序UID,EXTRA_ASSIST_CONTEXT爲正在輔助的程序的上下文環境,EXTRA_ASSIST_INPUT_HINT_KEYBOARD提示使用鍵盤爲主要輔助輸入設備,EXTRA_ASSIST_INPUT_DEVICE_ID爲輔助設備的device id

 1 1290    /**
 2 1291     * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
 3 1292     * application package at the time the assist was invoked.
 4 1293     */
 5 1294    public static final String EXTRA_ASSIST_PACKAGE
 6 1295            = "android.intent.extra.ASSIST_PACKAGE";
 7 1296
 8 1297    /**
 9 1298     * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
10 1299     * application package at the time the assist was invoked.
11 1300     */
12 1301    public static final String EXTRA_ASSIST_UID
13 1302            = "android.intent.extra.ASSIST_UID";
14 1303
15 1304    /**
16 1305     * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
17 1306     * information supplied by the current foreground app at the time of the assist request.
18 1307     * This is a {@link Bundle} of additional data.
19 1308     */
20 1309    public static final String EXTRA_ASSIST_CONTEXT
21 1310            = "android.intent.extra.ASSIST_CONTEXT";
22 1311
23 1312    /**
24 1313     * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
25 1314     * keyboard as the primary input device for assistance.
26 1315     */
27 1316    public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
28 1317            "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
29 1318
30 1319    /**
31 1320     * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
32 1321     * that was used to invoke the assist.
33 1322     */
34 1323    public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
35 1324            "android.intent.extra.ASSIST_INPUT_DEVICE_ID";

ACTION_ALL_APPS列出全部APP

1 1326    /**
2 1327     * Activity Action: List all available applications.
3 1328     * <p>Input: Nothing.
4 1329     * <p>Output: nothing.
5 1330     */
6 1331    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1332    public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";

ACTION_SET_WALLPAPER顯示壁紙設置界面

1 1333    /**
2 1334     * Activity Action: Show settings for choosing wallpaper.
3 1335     * <p>Input: Nothing.
4 1336     * <p>Output: Nothing.
5 1337     */
6 1338    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1339    public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";

ACTION_BUG_REPORT顯示bug report界面

1 1341    /**
2 1342     * Activity Action: Show activity for reporting a bug.
3 1343     * <p>Input: Nothing.
4 1344     * <p>Output: Nothing.
5 1345     */
6 1346    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1347    public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";

ACTION_FACTORY_TEST啓動工廠測試app

1 1349    /**
2 1350     *  Activity Action: Main entry point for factory tests.  Only used when
3 1351     *  the device is booting in factory test node.  The implementing package
4 1352     *  must be installed in the system image.
5 1353     *  <p>Input: nothing
6 1354     *  <p>Output: nothing
7 1355     */
8 1356    public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";

ACTION_CALL_BUTTON顯示CALL UI

1 1358    /**
2 1359     * Activity Action: The user pressed the "call" button to go to the dialer
3 1360     * or other appropriate UI for placing a call.
4 1361     * <p>Input: Nothing.
5 1362     * <p>Output: Nothing.
6 1363     */
7 1364    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
8 1365    public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
9 1366

ACTION_VOICE_COMMAND打開語音指令

1 1367    /**
2 1368     * Activity Action: Start Voice Command.
3 1369     * <p>Input: Nothing.
4 1370     * <p>Output: Nothing.
5 1371     */
6 1372    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1373    public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";

ACTION_SEARCH_LONG_PRESS啓動與長按search關聯的動做

1 1375    /**
2 1376     * Activity Action: Start action associated with long pressing on the
3 1377     * search key.
4 1378     * <p>Input: Nothing.
5 1379     * <p>Output: Nothing.
6 1380     */
7 1381    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
8 1382    public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";

ACTION_APP_ERROR報告crash/ANR信息

 1 1384    /**
 2 1385     * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
 3 1386     * This intent is delivered to the package which installed the application, usually
 4 1387     * Google Play.
 5 1388     * <p>Input: No data is specified. The bug report is passed in using
 6 1389     * an {@link #EXTRA_BUG_REPORT} field.
 7 1390     * <p>Output: Nothing.
 8 1391     *
 9 1392     * @see #EXTRA_BUG_REPORT
10 1393     */
11 1394    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
12 1395    public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
13 1396

ACTION_POWER_USAGE_SUMMARY顯示power使用狀況

1 1397    /**
2 1398     * Activity Action: Show power usage information to the user.
3 1399     * <p>Input: Nothing.
4 1400     * <p>Output: Nothing.
5 1401     */
6 1402    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1403    public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
8 1404

ACTION_UPGRADE_SETUP在平臺升級後啓動設置嚮導

 1 1405    /**
 2 1406     * Activity Action: Setup wizard to launch after a platform update.  This
 3 1407     * activity should have a string meta-data field associated with it,
 4 1408     * {@link #METADATA_SETUP_VERSION}, which defines the current version of
 5 1409     * the platform for setup.  The activity will be launched only if
 6 1410     * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
 7 1411     * same value.
 8 1412     * <p>Input: Nothing.
 9 1413     * <p>Output: Nothing.
10 1414     * @hide
11 1415     */
12 1416    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
13 1417    public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";

ACTION_SHOW_KEYBOARD_SHORTCUTS啓動鍵盤快捷助手屏幕

1 1419    /**
2 1420     * Activity Action: Start the Keyboard Shortcuts Helper screen.
3 1421     * <p>Input: Nothing.
4 1422     * <p>Output: Nothing.
5 1423     * @hide
6 1424     */
7 1425    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 1426    public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
9 1427            "android.intent.action.SHOW_KEYBOARD_SHORTCUTS";

ACTION_DISMISS_KEYBOARD_SHORTCUTS解除鍵盤快捷助手

1 1429    /**
2 1430     * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
3 1431     * <p>Input: Nothing.
4 1432     * <p>Output: Nothing.
5 1433     * @hide
6 1434     */
7 1435    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 1436    public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
9 1437            "android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";

ACTION_MANAGER_NETWORK_USAGE啓動網絡流量統計界面

1 1439    /**
2 1440     * Activity Action: Show settings for managing network data usage of a
3 1441     * specific application. Applications should define an activity that offers
4 1442     * options to control data usage.
5 1443     */
6 1444    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
7 1445    public static final String ACTION_MANAGE_NETWORK_USAGE =
8 1446            "android.intent.action.MANAGE_NETWORK_USAGE";

ACTION_INSTALL_PACKAGE啓動app安裝界面

 1 1448    /**
 2 1449     * Activity Action: Launch application installer.
 3 1450     * <p>
 4 1451     * Input: The data must be a content: or file: URI at which the application
 5 1452     * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
 6 1453     * you can also use "package:<package-name>" to install an application for the
 7 1454     * current user that is already installed for another user. You can optionally supply
 8 1455     * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
 9 1456     * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
10 1457     * <p>
11 1458     * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
12 1459     * succeeded.
13 1460     * <p>
14 1461     * <strong>Note:</strong>If your app is targeting API level higher than 22 you
15 1462     * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
16 1463     * in order to launch the application installer.
17 1464     * </p>
18 1465     *
19 1466     * @see #EXTRA_INSTALLER_PACKAGE_NAME
20 1467     * @see #EXTRA_NOT_UNKNOWN_SOURCE
21 1468     * @see #EXTRA_RETURN_RESULT
22 1469     */
23 1470    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
24 1471    public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";

ACTION_INSTALL_EPHEMERAL_PACKAGE和ACTION_RESOLVE_EPHEMERAl_PACKAGE和暫時行app有關,一個啓動臨時app安裝器,一個是解析臨時app

 1 1473    /**
 2 1474     * Activity Action: Launch ephemeral installer.
 3 1475     * <p>
 4 1476     * Input: The data must be a http: URI that the ephemeral application is registered
 5 1477     * to handle.
 6 1478     * <p class="note">
 7 1479     * This is a protected intent that can only be sent by the system.
 8 1480     * </p>
 9 1481     *
10 1482     * @hide
11 1483     */
12 1484    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
13 1485    public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
14 1486            = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
15 1487
16 1488    /**
17 1489     * Service Action: Resolve ephemeral application.
18 1490     * <p>
19 1491     * The system will have a persistent connection to this service.
20 1492     * This is a protected intent that can only be sent by the system.
21 1493     * </p>
22 1494     *
23 1495     * @hide
24 1496     */
25 1497    @SdkConstant(SdkConstantType.SERVICE_ACTION)
26 1498    public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
27 1499            = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
28 1500

與相關的幾個EXTRA,分別是安裝的包的名字,是不是未知源安裝,app來源,誰發出啓動動做的詳細信息的URI,誰發出啓動動做的詳細信息的String,安裝發起者UID,是否容許替換,是否返回安裝/卸載成功標誌,安裝結果標誌

 1 1501    /**
 2 1502     * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
 3 1503     * package.  Specifies the installer package name; this package will receive the
 4 1504     * {@link #ACTION_APP_ERROR} intent.
 5 1505     */
 6 1506    public static final String EXTRA_INSTALLER_PACKAGE_NAME
 7 1507            = "android.intent.extra.INSTALLER_PACKAGE_NAME";
 8 1508
 9 1509    /**
10 1510     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
11 1511     * package.  Specifies that the application being installed should not be
12 1512     * treated as coming from an unknown source, but as coming from the app
13 1513     * invoking the Intent.  For this to work you must start the installer with
14 1514     * startActivityForResult().
15 1515     */
16 1516    public static final String EXTRA_NOT_UNKNOWN_SOURCE
17 1517            = "android.intent.extra.NOT_UNKNOWN_SOURCE";
18 1518
19 1519    /**
20 1520     * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
21 1521     * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
22 1522     * data field originated from.
23 1523     */
24 1524    public static final String EXTRA_ORIGINATING_URI
25 1525            = "android.intent.extra.ORIGINATING_URI";
26 1526
27 1527    /**
28 1528     * This extra can be used with any Intent used to launch an activity, supplying information
29 1529     * about who is launching that activity.  This field contains a {@link android.net.Uri}
30 1530     * object, typically an http: or https: URI of the web site that the referral came from;
31 1531     * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
32 1532     * a native application that it came from.
33 1533     *
34 1534     * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
35 1535     * instead of directly retrieving the extra.  It is also valid for applications to
36 1536     * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
37 1537     * a string, not a Uri; the field here, if supplied, will always take precedence,
38 1538     * however.</p>
39 1539     *
40 1540     * @see #EXTRA_REFERRER_NAME
41 1541     */
42 1542    public static final String EXTRA_REFERRER
43 1543            = "android.intent.extra.REFERRER";
44 1544
45 1545    /**
46 1546     * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
47 1547     * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
48 1548     * not be created, in particular when Intent extras are supplied through the
49 1549     * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
50 1550     * schemes.
51 1551     *
52 1552     * @see #EXTRA_REFERRER
53 1553     */
54 1554    public static final String EXTRA_REFERRER_NAME
55 1555            = "android.intent.extra.REFERRER_NAME";
56 1556
57 1557    /**
58 1558     * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
59 1559     * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
60 1560     * @hide
61 1561     */
62 1562    @SystemApi
63 1563    public static final String EXTRA_ORIGINATING_UID
64 1564            = "android.intent.extra.ORIGINATING_UID";
65 1565
66 1566    /**
67 1567     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
68 1568     * package.  Tells the installer UI to skip the confirmation with the user
69 1569     * if the .apk is replacing an existing one.
70 1570     * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
71 1571     * will no longer show an interstitial message about updating existing
72 1572     * applications so this is no longer needed.
73 1573     */
74 1574    @Deprecated
75 1575    public static final String EXTRA_ALLOW_REPLACE
76 1576            = "android.intent.extra.ALLOW_REPLACE";
77 1577
78 1578    /**
79 1579     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
80 1580     * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
81 1581     * return to the application the result code of the install/uninstall.  The returned result
82 1582     * code will be {@link android.app.Activity#RESULT_OK} on success or
83 1583     * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
84 1584     */
85 1585    public static final String EXTRA_RETURN_RESULT
86 1586            = "android.intent.extra.RETURN_RESULT";
87 1587
88 1588    /**
89 1589     * Package manager install result code.  @hide because result codes are not
90 1590     * yet ready to be exposed.
91 1591     */
92 1592    public static final String EXTRA_INSTALL_RESULT
93 1593            = "android.intent.extra.INSTALL_RESULT";
94 1594

ACTION_UNINSTALL_PACKAGE卸載應用,EXTRA_UNINSTALL_ALL_USERS代表是否爲全部user卸載

 1 1595    /**
 2 1596     * Activity Action: Launch application uninstaller.
 3 1597     * <p>
 4 1598     * Input: The data must be a package: URI whose scheme specific part is
 5 1599     * the package name of the current installed package to be uninstalled.
 6 1600     * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
 7 1601     * <p>
 8 1602     * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
 9 1603     * succeeded.
10 1604     */
11 1605    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
12 1606    public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
13 1607
14 1608    /**
15 1609     * Specify whether the package should be uninstalled for all users.
16 1610     * @hide because these should not be part of normal application flow.
17 1611     */
18 1612    public static final String EXTRA_UNINSTALL_ALL_USERS
19 1613            = "android.intent.extra.UNINSTALL_ALL_USERS";

METADATA_SETUP_VERSION爲當前平臺版本

1 1615    /**
2 1616     * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
3 1617     * describing the last run version of the platform that was setup.
4 1618     * @hide
5 1619     */
6 1620    public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";

ACTION_MANAGE_APP_PERMISSIONS和ACTION_MANAGE_PERMISSIONS啓動UI管理權限

 1 1622    /**
 2 1623     * Activity action: Launch UI to manage the permissions of an app.
 3 1624     * <p>
 4 1625     * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
 5 1626     * will be managed by the launched UI.
 6 1627     * </p>
 7 1628     * <p>
 8 1629     * Output: Nothing.
 9 1630     * </p>
10 1631     *
11 1632     * @see #EXTRA_PACKAGE_NAME
12 1633     *
13 1634     * @hide
14 1635     */
15 1636    @SystemApi
16 1637    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
17 1638    public static final String ACTION_MANAGE_APP_PERMISSIONS =
18 1639            "android.intent.action.MANAGE_APP_PERMISSIONS";
19 1640
20 1641    /**
21 1642     * Activity action: Launch UI to manage permissions.
22 1643     * <p>
23 1644     * Input: Nothing.
24 1645     * </p>
25 1646     * <p>
26 1647     * Output: Nothing.
27 1648     * </p>
28 1649     *
29 1650     * @hide
30 1651     */
31 1652    @SystemApi
32 1653    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
33 1654    public static final String ACTION_MANAGE_PERMISSIONS =
34 1655            "android.intent.action.MANAGE_PERMISSIONS";
35 1656

ACTION_REVIEW_PERMISSIONS,review app的權限

 1 1657    /**
 2 1658     * Activity action: Launch UI to review permissions for an app.
 3 1659     * The system uses this intent if permission review for apps not
 4 1660     * supporting the new runtime permissions model is enabled. In
 5 1661     * this mode a permission review is required before any of the
 6 1662     * app components can run.
 7 1663     * <p>
 8 1664     * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
 9 1665     * permissions will be reviewed (mandatory).
10 1666     * </p>
11 1667     * <p>
12 1668     * Input: {@link #EXTRA_INTENT} specifies a pending intent to
13 1669     * be fired after the permission review (optional).
14 1670     * </p>
15 1671     * <p>
16 1672     * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
17 1673     * be invoked after the permission review (optional).
18 1674     * </p>
19 1675     * <p>
20 1676     * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
21 1677     * passed via {@link #EXTRA_INTENT} needs a result (optional).
22 1678     * </p>
23 1679     * <p>
24 1680     * Output: Nothing.
25 1681     * </p>
26 1682     *
27 1683     * @see #EXTRA_PACKAGE_NAME
28 1684     * @see #EXTRA_INTENT
29 1685     * @see #EXTRA_REMOTE_CALLBACK
30 1686     * @see #EXTRA_RESULT_NEEDED
31 1687     *
32 1688     * @hide
33 1689     */
34 1690    @SystemApi
35 1691    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
36 1692    public static final String ACTION_REVIEW_PERMISSIONS =
37 1693            "android.intent.action.REVIEW_PERMISSIONS";

下面的EXTRA與ACTION_REVIEW_PERMISSIONS有關,EXTRA_REMOTE_CALLBACK爲報告遠程結果的回調bundle,EXTRA_PACKAGE_NAME爲包名,EXTRA_RESULT_NEEDED說明是否須要返回結果

 1 1695    /**
 2 1696     * Intent extra: A callback for reporting remote result as a bundle.
 3 1697     * <p>
 4 1698     * Type: IRemoteCallback
 5 1699     * </p>
 6 1700     *
 7 1701     * @hide
 8 1702     */
 9 1703    @SystemApi
10 1704    public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
11 1705
12 1706    /**
13 1707     * Intent extra: An app package name.
14 1708     * <p>
15 1709     * Type: String
16 1710     * </p>
17 1711     *
18 1712     */
19 1713    public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
20 1714
21 1715    /**
22 1716     * Intent extra: An extra for specifying whether a result is needed.
23 1717     * <p>
24 1718     * Type: boolean
25 1719     * </p>
26 1720     *
27 1721     * @hide
28 1722     */
29 1723    @SystemApi
30 1724    public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
31 1725

ACTION_MANAGE_PERMISSION_APPS列舉擁有某個權限的app,EXTRA_PERMISSION_NAME爲權限名

 1 1726    /**
 2 1727     * Activity action: Launch UI to manage which apps have a given permission.
 3 1728     * <p>
 4 1729     * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
 5 1730     * to which will be managed by the launched UI.
 6 1731     * </p>
 7 1732     * <p>
 8 1733     * Output: Nothing.
 9 1734     * </p>
10 1735     *
11 1736     * @see #EXTRA_PERMISSION_NAME
12 1737     *
13 1738     * @hide
14 1739     */
15 1740    @SystemApi
16 1741    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
17 1742    public static final String ACTION_MANAGE_PERMISSION_APPS =
18 1743            "android.intent.action.MANAGE_PERMISSION_APPS";
19 1744
20 1745    /**
21 1746     * Intent extra: The name of a permission.
22 1747     * <p>
23 1748     * Type: String
24 1749     * </p>
25 1750     *
26 1751     * @hide
27 1752     */
28 1753    @SystemApi
29 1754    public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
30 1755

 

下面開始是給BroadcastReceiver接收處理的Action,代表了狀態的改變

ACTION_SCREEN_OFF和ACTION_SCREEN_ON對應手機是否可交互,而不是手機是否屏亮屏滅

 1 1756    // ---------------------------------------------------------------------
 2 1757    // ---------------------------------------------------------------------
 3 1758    // Standard intent broadcast actions (see action variable).
 4 1759
 5 1760    /**
 6 1761     * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
 7 1762     * <p>
 8 1763     * For historical reasons, the name of this broadcast action refers to the power
 9 1764     * state of the screen but it is actually sent in response to changes in the
10 1765     * overall interactive state of the device.
11 1766     * </p><p>
12 1767     * This broadcast is sent when the device becomes non-interactive which may have
13 1768     * nothing to do with the screen turning off.  To determine the
14 1769     * actual state of the screen, use {@link android.view.Display#getState}.
15 1770     * </p><p>
16 1771     * See {@link android.os.PowerManager#isInteractive} for details.
17 1772     * </p>
18 1773     * You <em>cannot</em> receive this through components declared in
19 1774     * manifests, only by explicitly registering for it with
20 1775     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
21 1776     * Context.registerReceiver()}.
22 1777     *
23 1778     * <p class="note">This is a protected intent that can only be sent
24 1779     * by the system.
25 1780     */
26 1781    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
27 1782    public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
28 1783
29 1784    /**
30 1785     * Broadcast Action: Sent when the device wakes up and becomes interactive.
31 1786     * <p>
32 1787     * For historical reasons, the name of this broadcast action refers to the power
33 1788     * state of the screen but it is actually sent in response to changes in the
34 1789     * overall interactive state of the device.
35 1790     * </p><p>
36 1791     * This broadcast is sent when the device becomes interactive which may have
37 1792     * nothing to do with the screen turning on.  To determine the
38 1793     * actual state of the screen, use {@link android.view.Display#getState}.
39 1794     * </p><p>
40 1795     * See {@link android.os.PowerManager#isInteractive} for details.
41 1796     * </p>
42 1797     * You <em>cannot</em> receive this through components declared in
43 1798     * manifests, only by explicitly registering for it with
44 1799     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
45 1800     * Context.registerReceiver()}.
46 1801     *
47 1802     * <p class="note">This is a protected intent that can only be sent
48 1803     * by the system.
49 1804     */
50 1805    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
51 1806    public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";

ACTION_DREAMING_STOPPED和ACTION_DREAMING_STARTED代表屏保開始與中止

 1 1808    /**
 2 1809     * Broadcast Action: Sent after the system stops dreaming.
 3 1810     *
 4 1811     * <p class="note">This is a protected intent that can only be sent by the system.
 5 1812     * It is only sent to registered receivers.</p>
 6 1813     */
 7 1814    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 8 1815    public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
 9 1816
10 1817    /**
11 1818     * Broadcast Action: Sent after the system starts dreaming.
12 1819     *
13 1820     * <p class="note">This is a protected intent that can only be sent by the system.
14 1821     * It is only sent to registered receivers.</p>
15 1822     */
16 1823    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
17 1824    public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";

ACTION_USER_PRESENT代表設備喚醒後用戶呈現出來

1 1826    /**
2 1827     * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
3 1828     * keyguard is gone).
4 1829     *
5 1830     * <p class="note">This is a protected intent that can only be sent
6 1831     * by the system.
7 1832     */
8 1833    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
9 1834    public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";

ACTION_TIME_TICK代表時間改變了;ACTION_TIME_CHANGED代表時間被設置;ACTION_DATE_CHANGED代表日期被改變;ACTION_TIMEZONE_CHANGED代表時間區被改變

 1 1836    /**
 2 1837     * Broadcast Action: The current time has changed.  Sent every
 3 1838     * minute.  You <em>cannot</em> receive this through components declared
 4 1839     * in manifests, only by explicitly registering for it with
 5 1840     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
 6 1841     * Context.registerReceiver()}.
 7 1842     *
 8 1843     * <p class="note">This is a protected intent that can only be sent
 9 1844     * by the system.
10 1845     */
11 1846    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
12 1847    public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
13 1848    /**
14 1849     * Broadcast Action: The time was set.
15 1850     */
16 1851    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
17 1852    public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
18 1853    /**
19 1854     * Broadcast Action: The date has changed.
20 1855     */
21 1856    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
22 1857    public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
23 1858    /**
24 1859     * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
25 1860     * <ul>
26 1861     *   <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
27 1862     * </ul>
28 1863     *
29 1864     * <p class="note">This is a protected intent that can only be sent
30 1865     * by the system.
31 1866     */
32 1867    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
33 1868    public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";

ACTION_CLEAR_DNS_CACHE代表DNS改變了

1 1869    /**
2 1870     * Clear DNS Cache Action: This is broadcast when networks have changed and old
3 1871     * DNS entries should be tossed.
4 1872     * @hide
5 1873     */
6 1874    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
7 1875    public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";

ACTION_ALARM_CHANGED代表alarm設置或被取消

1 1876    /**
2 1877     * Alarm Changed Action: This is broadcast when the AlarmClock
3 1878     * application's alarm is set or unset.  It is used by the
4 1879     * AlarmClock application and the StatusBar service.
5 1880     * @hide
6 1881     */
7 1882    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 1883    public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
9 1884

ACTION_LOCKED_BOOT_COMPLETE代表啓動完成,沒解鎖;ACTION_BOOT_COMPLETE代表啓動完成,也解鎖了

 1 1885    /**
 2 1886     * Broadcast Action: This is broadcast once, after the user has finished
 3 1887     * booting, but while still in the "locked" state. It can be used to perform
 4 1888     * application-specific initialization, such as installing alarms. You must
 5 1889     * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
 6 1890     * permission in order to receive this broadcast.
 7 1891     * <p>
 8 1892     * This broadcast is sent immediately at boot by all devices (regardless of
 9 1893     * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
10 1894     * higher. Upon receipt of this broadcast, the user is still locked and only
11 1895     * device-protected storage can be accessed safely. If you want to access
12 1896     * credential-protected storage, you need to wait for the user to be
13 1897     * unlocked (typically by entering their lock pattern or PIN for the first
14 1898     * time), after which the {@link #ACTION_USER_UNLOCKED} and
15 1899     * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
16 1900     * <p>
17 1901     * To receive this broadcast, your receiver component must be marked as
18 1902     * being {@link ComponentInfo#directBootAware}.
19 1903     * <p class="note">
20 1904     * This is a protected intent that can only be sent by the system.
21 1905     *
22 1906     * @see Context#createDeviceProtectedStorageContext()
23 1907     */
24 1908    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
25 1909    public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
26 1910
27 1911    /**
28 1912     * Broadcast Action: This is broadcast once, after the user has finished
29 1913     * booting. It can be used to perform application-specific initialization,
30 1914     * such as installing alarms. You must hold the
31 1915     * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
32 1916     * order to receive this broadcast.
33 1917     * <p>
34 1918     * This broadcast is sent at boot by all devices (both with and without
35 1919     * direct boot support). Upon receipt of this broadcast, the user is
36 1920     * unlocked and both device-protected and credential-protected storage can
37 1921     * accessed safely.
38 1922     * <p>
39 1923     * If you need to run while the user is still locked (before they've entered
40 1924     * their lock pattern or PIN for the first time), you can listen for the
41 1925     * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
42 1926     * <p class="note">
43 1927     * This is a protected intent that can only be sent by the system.
44 1928     */
45 1929    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
46 1930    public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";

ACTION_CLOSE_SYSTEM_DIALOGS通知關閉臨時系統對話框

1 1931
2 1932    /**
3 1933     * Broadcast Action: This is broadcast when a user action should request a
4 1934     * temporary system dialog to dismiss.  Some examples of temporary system
5 1935     * dialogs are the notification window-shade and the recent tasks dialog.
6 1936     */
7 1937    public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
8 1938    /**

ACTION_PACKAGE_INSTALL觸發安裝一個包,已被廢棄

 1 1938    /**
 2 1939     * Broadcast Action: Trigger the download and eventual installation
 3 1940     * of a package.
 4 1941     * <p>Input: {@link #getData} is the URI of the package file to download.
 5 1942     *
 6 1943     * <p class="note">This is a protected intent that can only be sent
 7 1944     * by the system.
 8 1945     *
 9 1946     * @deprecated This constant has never been used.
10 1947     */
11 1948    @Deprecated
12 1949    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
13 1950    public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";

ACTION_PACKAGE_ADDED,ACTION_PACKAGE_REPLACED代表PACKAGE被安裝和被更新

 1 1951    /**
 2 1952     * Broadcast Action: A new application package has been installed on the
 3 1953     * device. The data contains the name of the package.  Note that the
 4 1954     * newly installed package does <em>not</em> receive this broadcast.
 5 1955     * <p>May include the following extras:
 6 1956     * <ul>
 7 1957     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
 8 1958     * <li> {@link #EXTRA_REPLACING} is set to true if this is following
 9 1959     * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
10 1960     * </ul>
11 1961     *
12 1962     * <p class="note">This is a protected intent that can only be sent
13 1963     * by the system.
14 1964     */
15 1965    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
16 1966    public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
17 1967    /**
18 1968     * Broadcast Action: A new version of an application package has been
19 1969     * installed, replacing an existing version that was previously installed.
20 1970     * The data contains the name of the package.
21 1971     * <p>May include the following extras:
22 1972     * <ul>
23 1973     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
24 1974     * </ul>
25 1975     *
26 1976     * <p class="note">This is a protected intent that can only be sent
27 1977     * by the system.
28 1978     */
29 1979    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
30 1980    public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";

ACTION_MY_PACKAGE_RELACED代表當前app被更新

 1 1981    /**
 2 1982     * Broadcast Action: A new version of your application has been installed
 3 1983     * over an existing one.  This is only sent to the application that was
 4 1984     * replaced.  It does not contain any additional data; to receive it, just
 5 1985     * use an intent filter for this action.
 6 1986     *
 7 1987     * <p class="note">This is a protected intent that can only be sent
 8 1988     * by the system.
 9 1989     */
10 1990    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
11 1991    public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";

ACTION_PACKAGE_REMOVED代表app被刪除,ACTION_PACKAGE_COMPLETELY_REMOVED代表被完全刪除,code和data都沒了,也不會被後續replaced

 1 1992    /**
 2 1993     * Broadcast Action: An existing application package has been removed from
 3 1994     * the device.  The data contains the name of the package.  The package
 4 1995     * that is being removed does <em>not</em> receive this Intent.
 5 1996     * <ul>
 6 1997     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
 7 1998     * to the package.
 8 1999     * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
 9 2000     * application -- data and code -- is being removed.
10 2001     * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
11 2002     * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
12 2003     * </ul>
13 2004     *
14 2005     * <p class="note">This is a protected intent that can only be sent
15 2006     * by the system.
16 2007     */
17 2008    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
18 2009    public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
19 2010    /**
20 2011     * Broadcast Action: An existing application package has been completely
21 2012     * removed from the device.  The data contains the name of the package.
22 2013     * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
23 2014     * {@link #EXTRA_DATA_REMOVED} is true and
24 2015     * {@link #EXTRA_REPLACING} is false of that broadcast.
25 2016     *
26 2017     * <ul>
27 2018     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
28 2019     * to the package.
29 2020     * </ul>
30 2021     *
31 2022     * <p class="note">This is a protected intent that can only be sent
32 2023     * by the system.
33 2024     */
34 2025    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
35 2026    public static final String ACTION_PACKAGE_FULLY_REMOVED
36 2027            = "android.intent.action.PACKAGE_FULLY_REMOVED";

ACTION_PACKAGE_CHANGED代表某個app package被改變了,好比某個component被使能。

 1 2028    /**
 2 2029     * Broadcast Action: An existing application package has been changed (for
 3 2030     * example, a component has been enabled or disabled).  The data contains
 4 2031     * the name of the package.
 5 2032     * <ul>
 6 2033     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
 7 2034     * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
 8 2035     * of the changed components (or the package name itself).
 9 2036     * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
10 2037     * default action of restarting the application.
11 2038     * </ul>
12 2039     *
13 2040     * <p class="note">This is a protected intent that can only be sent
14 2041     * by the system.
15 2042     */
16 2043    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
17 2044    public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";

ACTION_QUERY_PACKAGE_RESTART詢問系統package是否須要被重啓

 1 2045    /**
 2 2046     * @hide
 3 2047     * Broadcast Action: Ask system services if there is any reason to
 4 2048     * restart the given package.  The data contains the name of the
 5 2049     * package.
 6 2050     * <ul>
 7 2051     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
 8 2052     * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
 9 2053     * </ul>
10 2054     *
11 2055     * <p class="note">This is a protected intent that can only be sent
12 2056     * by the system.
13 2057     */
14 2058    @SystemApi
15 2059    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
16 2060    public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";

ACTION_PACKAGE_RESTARTED代表某個package被restarted了

 1 2061    /**
 2 2062     * Broadcast Action: The user has restarted a package, and all of its
 3 2063     * processes have been killed.  All runtime state
 4 2064     * associated with it (processes, alarms, notifications, etc) should
 5 2065     * be removed.  Note that the restarted package does <em>not</em>
 6 2066     * receive this broadcast.
 7 2067     * The data contains the name of the package.
 8 2068     * <ul>
 9 2069     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
10 2070     * </ul>
11 2071     *
12 2072     * <p class="note">This is a protected intent that can only be sent
13 2073     * by the system.
14 2074     */
15 2075    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
16 2076    public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";

ACTION_PACKAGE_DATA_CLEARED代表程序數據被清空;ACTION_PACKAGES_SUSPENDED代表package被掛起;ACTION_PACKAGES_UNSUSPEND代表package被喚醒;ACTION_UID_REMOVED代表某個UID的用戶被移除了

 1 2077    /**
 2 2078     * Broadcast Action: The user has cleared the data of a package.  This should
 3 2079     * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
 4 2080     * its persistent data is erased and this broadcast sent.
 5 2081     * Note that the cleared package does <em>not</em>
 6 2082     * receive this broadcast. The data contains the name of the package.
 7 2083     * <ul>
 8 2084     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
 9 2085     * </ul>
10 2086     *
11 2087     * <p class="note">This is a protected intent that can only be sent
12 2088     * by the system.
13 2089     */
14 2090    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
15 2091    public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
16 2092    /**
17 2093     * Broadcast Action: Packages have been suspended.
18 2094     * <p>Includes the following extras:
19 2095     * <ul>
20 2096     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
21 2097     * </ul>
22 2098     *
23 2099     * <p class="note">This is a protected intent that can only be sent
24 2100     * by the system. It is only sent to registered receivers.
25 2101     */
26 2102    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
27 2103    public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
28 2104    /**
29 2105     * Broadcast Action: Packages have been unsuspended.
30 2106     * <p>Includes the following extras:
31 2107     * <ul>
32 2108     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
33 2109     * </ul>
34 2110     *
35 2111     * <p class="note">This is a protected intent that can only be sent
36 2112     * by the system. It is only sent to registered receivers.
37 2113     */
38 2114    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
39 2115    public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
40 2116    /**
41 2117     * Broadcast Action: A user ID has been removed from the system.  The user
42 2118     * ID number is stored in the extra data under {@link #EXTRA_UID}.
43 2119     *
44 2120     * <p class="note">This is a protected intent that can only be sent
45 2121     * by the system.
46 2122     */
47 2123    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
48 2124    public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";

ACTION_PACKAGE_FIRST_LAUNCH幫忙package第一次被啓動;ACTION_PACKAGE_NEEDS_VERIFICATION代表package要被驗證;ACTION_PACKAGE_VERIFIED代表package已經被驗證過

 1 2126    /**
 2 2127     * Broadcast Action: Sent to the installer package of an application when
 3 2128     * that application is first launched (that is the first time it is moved
 4 2129     * out of the stopped state).  The data contains the name of the package.
 5 2130     *
 6 2131     * <p class="note">This is a protected intent that can only be sent
 7 2132     * by the system.
 8 2133     */
 9 2134    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
10 2135    public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
11 2136
12 2137    /**
13 2138     * Broadcast Action: Sent to the system package verifier when a package
14 2139     * needs to be verified. The data contains the package URI.
15 2140     * <p class="note">
16 2141     * This is a protected intent that can only be sent by the system.
17 2142     * </p>
18 2143     */
19 2144    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
20 2145    public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
21 2146
22 2147    /**
23 2148     * Broadcast Action: Sent to the system package verifier when a package is
24 2149     * verified. The data contains the package URI.
25 2150     * <p class="note">
26 2151     * This is a protected intent that can only be sent by the system.
27 2152     */
28 2153    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
29 2154    public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
30 2155

ACTION_INTENT_FILTER_NEEDS_VERIFICATION告訴系統intent filter verifier,有intent filter須要verification

 1 2156    /**
 2 2157     * Broadcast Action: Sent to the system intent filter verifier when an
 3 2158     * intent filter needs to be verified. The data contains the filter data
 4 2159     * hosts to be verified against.
 5 2160     * <p class="note">
 6 2161     * This is a protected intent that can only be sent by the system.
 7 2162     * </p>
 8 2163     *
 9 2164     * @hide
10 2165     */
11 2166    @SystemApi
12 2167    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
13 2168    public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";

ACTION_EXTERNAL_APPLICATIONS_AVAILABLE,ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE代表在外部媒體介質上的應用程序列表可用和不可用

 1 2170    /**
 2 2171     * Broadcast Action: Resources for a set of packages (which were
 3 2172     * previously unavailable) are currently
 4 2173     * available since the media on which they exist is available.
 5 2174     * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
 6 2175     * list of packages whose availability changed.
 7 2176     * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
 8 2177     * list of uids of packages whose availability changed.
 9 2178     * Note that the
10 2179     * packages in this list do <em>not</em> receive this broadcast.
11 2180     * The specified set of packages are now available on the system.
12 2181     * <p>Includes the following extras:
13 2182     * <ul>
14 2183     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
15 2184     * whose resources(were previously unavailable) are currently available.
16 2185     * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
17 2186     * packages whose resources(were previously unavailable)
18 2187     * are  currently available.
19 2188     * </ul>
20 2189     *
21 2190     * <p class="note">This is a protected intent that can only be sent
22 2191     * by the system.
23 2192     */
24 2193    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
25 2194    public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
26 2195        "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
27 2196
28 2197    /**
29 2198     * Broadcast Action: Resources for a set of packages are currently
30 2199     * unavailable since the media on which they exist is unavailable.
31 2200     * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
32 2201     * list of packages whose availability changed.
33 2202     * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
34 2203     * list of uids of packages whose availability changed.
35 2204     * The specified set of packages can no longer be
36 2205     * launched and are practically unavailable on the system.
37 2206     * <p>Inclues the following extras:
38 2207     * <ul>
39 2208     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
40 2209     * whose resources are no longer available.
41 2210     * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
42 2211     * whose resources are no longer available.
43 2212     * </ul>
44 2213     *
45 2214     * <p class="note">This is a protected intent that can only be sent
46 2215     * by the system.
47 2216     */
48 2217    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
49 2218    public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
50 2219        "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
51 2220

 ACTION_PREFERRED_ACTIVITY_CHANGED代表被優先選擇的activity有改動

 1 221    /**
 2 2222     * Broadcast Action: preferred activities have changed *explicitly*.
 3 2223     *
 4 2224     * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
 5 2225     * when an app is installed or uninstalled, but in such cases this broadcast will *not*
 6 2226     * be sent.
 7 2227     *
 8 2228     * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
 9 2229     *
10 2230     * @hide
11 2231     */
12 2232    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
13 2233    public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
14 2234            "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
15 2235

ACTION_WALLPAPER_CHANGED代表壁紙被改了,已被棄用

 1 2237    /**
 2 2238     * Broadcast Action:  The current system wallpaper has changed.  See
 3 2239     * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
 4 2240     * This should <em>only</em> be used to determine when the wallpaper
 5 2241     * has changed to show the new wallpaper to the user.  You should certainly
 6 2242     * never, in response to this, change the wallpaper or other attributes of
 7 2243     * it such as the suggested size.  That would be crazy, right?  You'd cause
 8 2244     * all kinds of loops, especially if other apps are doing similar things,
 9 2245     * right?  Of course.  So please don't do this.
10 2246     *
11 2247     * @deprecated Modern applications should use
12 2248     * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
13 2249     * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
14 2250     * shown behind their UI, rather than watching for this broadcast and
15 2251     * rendering the wallpaper on their own.
16 2252     */
17 2253    @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
18 2254    public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";

ACTION_CONFIGURATION_CHANGED代表配置被改變了,好比地區,定向等

 1 2255    /**
 2 2256     * Broadcast Action: The current device {@link android.content.res.Configuration}
 3 2257     * (orientation, locale, etc) has changed.  When such a change happens, the
 4 2258     * UIs (view hierarchy) will need to be rebuilt based on this new
 5 2259     * information; for the most part, applications don't need to worry about
 6 2260     * this, because the system will take care of stopping and restarting the
 7 2261     * application to make sure it sees the new changes.  Some system code that
 8 2262     * can not be restarted will need to watch for this action and handle it
 9 2263     * appropriately.
10 2264     *
11 2265     * <p class="note">
12 2266     * You <em>cannot</em> receive this through components declared
13 2267     * in manifests, only by explicitly registering for it with
14 2268     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
15 2269     * Context.registerReceiver()}.
16 2270     *
17 2271     * <p class="note">This is a protected intent that can only be sent
18 2272     * by the system.
19 2273     *
20 2274     * @see android.content.res.Configuration
21 2275     */
22 2276    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
23 2277    public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";

ACTION_LOCALE_CHANGED代表地區改變

1 2278    /**
2 2279     * Broadcast Action: The current device's locale has changed.
3 2280     *
4 2281     * <p class="note">This is a protected intent that can only be sent
5 2282     * by the system.
6 2283     */
7 2284    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 2285    public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";

ACTION_BATTER_CHANGED代表battery長點狀態與級別被改變;ACTION_BATTERY_LOW代表電量低;ACTION_BATTERY_OK代表電量不低了

 1 2286    /**
 2 2287     * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
 3 2288     * charging state, level, and other information about the battery.
 4 2289     * See {@link android.os.BatteryManager} for documentation on the
 5 2290     * contents of the Intent.
 6 2291     *
 7 2292     * <p class="note">
 8 2293     * You <em>cannot</em> receive this through components declared
 9 2294     * in manifests, only by explicitly registering for it with
10 2295     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
11 2296     * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
12 2297     * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
13 2298     * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
14 2299     * broadcasts that are sent and can be received through manifest
15 2300     * receivers.
16 2301     *
17 2302     * <p class="note">This is a protected intent that can only be sent
18 2303     * by the system.
19 2304     */
20 2305    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
21 2306    public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
22 2307    /**
23 2308     * Broadcast Action:  Indicates low battery condition on the device.
24 2309     * This broadcast corresponds to the "Low battery warning" system dialog.
25 2310     *
26 2311     * <p class="note">This is a protected intent that can only be sent
27 2312     * by the system.
28 2313     */
29 2314    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
30 2315    public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
31 2316    /**
32 2317     * Broadcast Action:  Indicates the battery is now okay after being low.
33 2318     * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
34 2319     * gone back up to an okay state.
35 2320     *
36 2321     * <p class="note">This is a protected intent that can only be sent
37 2322     * by the system.
38 2323     */
39 2324    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
40 2325    public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
41 2326    /**

ACTION_POWER_CONNECTED和ACTION_POWER_DISCONNECTED代表充電器鏈接和斷開

 1 2326    /**
 2 2327     * Broadcast Action:  External power has been connected to the device.
 3 2328     * This is intended for applications that wish to register specifically to this notification.
 4 2329     * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
 5 2330     * stay active to receive this notification.  This action can be used to implement actions
 6 2331     * that wait until power is available to trigger.
 7 2332     *
 8 2333     * <p class="note">This is a protected intent that can only be sent
 9 2334     * by the system.
10 2335     */
11 2336    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
12 2337    public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
13 2338    /**
14 2339     * Broadcast Action:  External power has been removed from the device.
15 2340     * This is intended for applications that wish to register specifically to this notification.
16 2341     * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
17 2342     * stay active to receive this notification.  This action can be used to implement actions
18 2343     * that wait until power is available to trigger.
19 2344     *
20 2345     * <p class="note">This is a protected intent that can only be sent
21 2346     * by the system.
22 2347     */
23 2348    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
24 2349    public static final String ACTION_POWER_DISCONNECTED =
25 2350            "android.intent.action.ACTION_POWER_DISCONNECTED";

ACTION_SHUTDOWN和ACTION_REQUEST_SHUTDOWN代表系統開始shutdown和要求shutdown

 1 2351    /**
 2 2352     * Broadcast Action:  Device is shutting down.
 3 2353     * This is broadcast when the device is being shut down (completely turned
 4 2354     * off, not sleeping).  Once the broadcast is complete, the final shutdown
 5 2355     * will proceed and all unsaved data lost.  Apps will not normally need
 6 2356     * to handle this, since the foreground activity will be paused as well.
 7 2357     *
 8 2358     * <p class="note">This is a protected intent that can only be sent
 9 2359     * by the system.
10 2360     * <p>May include the following extras:
11 2361     * <ul>
12 2362     * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
13 2363     * shutdown is only for userspace processes.  If not set, assumed to be false.
14 2364     * </ul>
15 2365     */
16 2366    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
17 2367    public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
18 2368    /**
19 2369     * Activity Action:  Start this activity to request system shutdown.
20 2370     * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
21 2371     * to request confirmation from the user before shutting down. The optional boolean
22 2372     * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
23 2373     * indicate that the shutdown is requested by the user.
24 2374     *
25 2375     * <p class="note">This is a protected intent that can only be sent
26 2376     * by the system.
27 2377     *
28 2378     * {@hide}
29 2379     */
30 2380    public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";

ACTION_DEVICE_STORAGE_LOW代表設備存儲低;ACTION_DEVICE_STORAGE_OK代表設備存儲不在低;ACTION_DEVICE_STORAGE_FULL代表設備存儲空間已滿;ACTION_DEVICE_STORAGE_NOT_FULL代表設備存儲空間不在已滿

 1 2381    /**
 2 2382     * Broadcast Action:  A sticky broadcast that indicates low memory
 3 2383     * condition on the device
 4 2384     *
 5 2385     * <p class="note">This is a protected intent that can only be sent
 6 2386     * by the system.
 7 2387     */
 8 2388    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 9 2389    public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
10 2390    /**
11 2391     * Broadcast Action:  Indicates low memory condition on the device no longer exists
12 2392     *
13 2393     * <p class="note">This is a protected intent that can only be sent
14 2394     * by the system.
15 2395     */
16 2396    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
17 2397    public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
18 2398    /**
19 2399     * Broadcast Action:  A sticky broadcast that indicates a memory full
20 2400     * condition on the device. This is intended for activities that want
21 2401     * to be able to fill the data partition completely, leaving only
22 2402     * enough free space to prevent system-wide SQLite failures.
23 2403     *
24 2404     * <p class="note">This is a protected intent that can only be sent
25 2405     * by the system.
26 2406     *
27 2407     * {@hide}
28 2408     */
29 2409    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
30 2410    public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
31 2411    /**
32 2412     * Broadcast Action:  Indicates memory full condition on the device
33 2413     * no longer exists.
34 2414     *
35 2415     * <p class="note">This is a protected intent that can only be sent
36 2416     * by the system.
37 2417     *
38 2418     * {@hide}
39 2419     */
40 2420    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
41 2421    public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";

ACTION_MANAGE_PACKAGE_STORAGE代表存儲空間已滿,要來管理存儲空間

1 2422    /**
2 2423     * Broadcast Action:  Indicates low memory condition notification acknowledged by user
3 2424     * and package management should be started.
4 2425     * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
5 2426     * notification.
6 2427     */
7 2428    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 2429    public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";

ACTION_UMS_CONNECTED代表進入USB MASS Storage模式;ACTION_UMS_DISCONNECTED代表斷開USB Mass Storage模式。這兩個已經被廢棄

 1 2430    /**
 2 2431     * Broadcast Action:  The device has entered USB Mass Storage mode.
 3 2432     * This is used mainly for the USB Settings panel.
 4 2433     * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
 5 2434     * when the SD card file system is mounted or unmounted
 6 2435     * @deprecated replaced by android.os.storage.StorageEventListener
 7 2436     */
 8 2437    @Deprecated
 9 2438    public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
10 2439
11 2440    /**
12 2441     * Broadcast Action:  The device has exited USB Mass Storage mode.
13 2442     * This is used mainly for the USB Settings panel.
14 2443     * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
15 2444     * when the SD card file system is mounted or unmounted
16 2445     * @deprecated replaced by android.os.storage.StorageEventListener
17 2446     */
18 2447    @Deprecated
19 2448    public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";

ACTION_MEDIA_REMOVED代表外部媒介已經被移除;ACTION_MEIDA_UNMOUNTED代表外部媒介被unmount了;ACTION_MEIDA_CHECKING代表媒介正在被檢查;ACTION_MEDIA_NOFS代表外部媒介上沒有fs;ACTION_MEDIA_MOUNTED代表外部媒介已經被掛載;ACTION_MEIDA_SHARED代表外部存儲介質被share爲UMS;ACTION_MEDIA_UNSHARED代表外部媒介再也不被share成UMS;ACTION_MEDIA_BAD_REMOVAL代表外部sd卡不在了,可是沒有unmount;ACTION_MEDIA_UNMOUNTABLE代表外部媒介存在可是沒法mount;ACTION_MEDIA_EJECT代表設備被彈出;ACTION_MEDIA_SCANNER_STARTED代表媒介掃描開始;ACTION_MEDIA_SCANNER_FINISHED代表媒介掃描結束;ACTION_MEDIA_SCANNER_SCAN_FILE代表請求外部媒介掃描某個文件並加入媒體數據庫;ACTION_MEDIA_BUTTON代表media按鈕被按下

  1 2450    /**
  2 2451     * Broadcast Action:  External media has been removed.
  3 2452     * The path to the mount point for the removed media is contained in the Intent.mData field.
  4 2453     */
  5 2454    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
  6 2455    public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
  7 2456
  8 2457    /**
  9 2458     * Broadcast Action:  External media is present, but not mounted at its mount point.
 10 2459     * The path to the mount point for the unmounted media is contained in the Intent.mData field.
 11 2460     */
 12 2461    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 13 2462    public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
 14 2463
 15 2464    /**
 16 2465     * Broadcast Action:  External media is present, and being disk-checked
 17 2466     * The path to the mount point for the checking media is contained in the Intent.mData field.
 18 2467     */
 19 2468    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 20 2469    public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
 21 2470
 22 2471    /**
 23 2472     * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
 24 2473     * The path to the mount point for the checking media is contained in the Intent.mData field.
 25 2474     */
 26 2475    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 27 2476    public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
 28 2477
 29 2478    /**
 30 2479     * Broadcast Action:  External media is present and mounted at its mount point.
 31 2480     * The path to the mount point for the mounted media is contained in the Intent.mData field.
 32 2481     * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
 33 2482     * media was mounted read only.
 34 2483     */
 35 2484    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 36 2485    public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
 37 2486
 38 2487    /**
 39 2488     * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
 40 2489     * The path to the mount point for the shared media is contained in the Intent.mData field.
 41 2490     */
 42 2491    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 43 2492    public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
 44 2493
 45 2494    /**
 46 2495     * Broadcast Action:  External media is no longer being shared via USB mass storage.
 47 2496     * The path to the mount point for the previously shared media is contained in the Intent.mData field.
 48 2497     *
 49 2498     * @hide
 50 2499     */
 51 2500    public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
 52 2501
 53 2502    /**
 54 2503     * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
 55 2504     * The path to the mount point for the removed media is contained in the Intent.mData field.
 56 2505     */
 57 2506    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 58 2507    public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
 59 2508
 60 2509    /**
 61 2510     * Broadcast Action:  External media is present but cannot be mounted.
 62 2511     * The path to the mount point for the unmountable media is contained in the Intent.mData field.
 63 2512     */
 64 2513    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 65 2514    public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
 66 2515
 67 2516   /**
 68 2517     * Broadcast Action:  User has expressed the desire to remove the external storage media.
 69 2518     * Applications should close all files they have open within the mount point when they receive this intent.
 70 2519     * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
 71 2520     */
 72 2521    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 73 2522    public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
 74 2523
 75 2524    /**
 76 2525     * Broadcast Action:  The media scanner has started scanning a directory.
 77 2526     * The path to the directory being scanned is contained in the Intent.mData field.
 78 2527     */
 79 2528    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 80 2529    public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
 81 2530
 82 2531   /**
 83 2532     * Broadcast Action:  The media scanner has finished scanning a directory.
 84 2533     * The path to the scanned directory is contained in the Intent.mData field.
 85 2534     */
 86 2535    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 87 2536    public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
 88 2537
 89 2538   /**
 90 2539     * Broadcast Action:  Request the media scanner to scan a file and add it to the media database.
 91 2540     * The path to the file is contained in the Intent.mData field.
 92 2541     */
 93 2542    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 94 2543    public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
 95 2544
 96 2545   /**
 97 2546     * Broadcast Action:  The "Media Button" was pressed.  Includes a single
 98 2547     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
 99 2548     * caused the broadcast.
100 2549     */
101 2550    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
102 2551    public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";

ACTION_CAMERA_BUTTON代表camera按鈕被按下了

1 2552
2 2553    /**
3 2554     * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
4 2555     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
5 2556     * caused the broadcast.
6 2557     */
7 2558    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 2559    public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";

ACTION_GTALK_SERVICE_CONNECTED和ACTION_GTALK_SERVICE_DISCONNECTED代表gtalk服務鏈接和斷開

 1 2561    // *** NOTE: @todo(*) The following really should go into a more domain-specific
 2 2562    // location; they are not general-purpose actions.
 3 2563
 4 2564    /**
 5 2565     * Broadcast Action: A GTalk connection has been established.
 6 2566     */
 7 2567    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 8 2568    public static final String ACTION_GTALK_SERVICE_CONNECTED =
 9 2569            "android.intent.action.GTALK_CONNECTED";
10 2570
11 2571    /**
12 2572     * Broadcast Action: A GTalk connection has been disconnected.
13 2573     */
14 2574    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
15 2575    public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
16 2576            "android.intent.action.GTALK_DISCONNECTED";
17 2577

ACTION_INPUT_METHOD_CHANGED代表輸入法改變

1 2578    /**
2 2579     * Broadcast Action: An input method has been changed.
3 2580     */
4 2581    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
5 2582    public static final String ACTION_INPUT_METHOD_CHANGED =
6 2583            "android.intent.action.INPUT_METHOD_CHANGED";
7 2584

 ACTION_AIRPLANE_MODE_CHANGED代表進入仍是退出飛行模式

 1 2585    /**
 2 2586     * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
 3 2587     * more radios have been turned off or on. The intent will have the following extra value:</p>
 4 2588     * <ul>
 5 2589     *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
 6 2590     *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
 7 2591     *   turned off</li>
 8 2592     * </ul>
 9 2593     *
10 2594     * <p class="note">This is a protected intent that can only be sent by the system.</p>
11 2595     */
12 2596    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
13 2597    public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";

ACTION_PROVIDER_CHANGED代表content provider維護的內容有變化。

 1 2599    /**
 2 2600     * Broadcast Action: Some content providers have parts of their namespace
 3 2601     * where they publish new events or items that the user may be especially
 4 2602     * interested in. For these things, they may broadcast this action when the
 5 2603     * set of interesting items change.
 6 2604     *
 7 2605     * For example, GmailProvider sends this notification when the set of unread
 8 2606     * mail in the inbox changes.
 9 2607     *
10 2608     * <p>The data of the intent identifies which part of which provider
11 2609     * changed. When queried through the content resolver, the data URI will
12 2610     * return the data set in question.
13 2611     *
14 2612     * <p>The intent will have the following extra values:
15 2613     * <ul>
16 2614     *   <li><em>count</em> - The number of items in the data set. This is the
17 2615     *       same as the number of items in the cursor returned by querying the
18 2616     *       data URI. </li>
19 2617     * </ul>
20 2618     *
21 2619     * This intent will be sent at boot (if the count is non-zero) and when the
22 2620     * data set changes. It is possible for the data set to change without the
23 2621     * count changing (for example, if a new unread message arrives in the same
24 2622     * sync operation in which a message is archived). The phone should still
25 2623     * ring/vibrate/etc as normal in this case.
26 2624     */
27 2625    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
28 2626    public static final String ACTION_PROVIDER_CHANGED =
29 2627            "android.intent.action.PROVIDER_CHANGED";

ACTION_HEADSET_PLUG代表有耳機插入或拔出

 1 2629    /**
 2 2630     * Broadcast Action: Wired Headset plugged in or unplugged.
 3 2631     *
 4 2632     * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
 5 2633     *   and documentation.
 6 2634     * <p>If the minimum SDK version of your application is
 7 2635     * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
 8 2636     * to the <code>AudioManager</code> constant in your receiver registration code instead.
 9 2637     */
10 2638    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
11 2639    public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;

ACTION_ADVANCED_SETTINGS_CHANGED代表切換到了高級設置上

 1 2641    /**
 2 2642     * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
 3 2643     * <ul>
 4 2644     *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
 5 2645     * </ul>
 6 2646     *
 7 2647     * <p class="note">This is a protected intent that can only be sent
 8 2648     * by the system.
 9 2649     *
10 2650     * @hide
11 2651     */
12 2652    //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
13 2653    public static final String ACTION_ADVANCED_SETTINGS_CHANGED
14 2654            = "android.intent.action.ADVANCED_SETTINGS";

ACTION_APPLICATION_RESTRICTRATIONS_CHANGED代表應用限制被改變

1 2656    /**
2 2657     *  Broadcast Action: Sent after application restrictions are changed.
3 2658     *
4 2659     * <p class="note">This is a protected intent that can only be sent
5 2660     * by the system.</p>
6 2661     */
7 2662    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
8 2663    public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
9 2664            "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";

ACTION_NEW_OUTGOING_CALL代表有新的外撥電話,能夠接受這個Intent修改要撥出的號碼或者阻止撥出

 1 2666    /**
 2 2667     * Broadcast Action: An outgoing call is about to be placed.
 3 2668     *
 4 2669     * <p>The Intent will have the following extra value:</p>
 5 2670     * <ul>
 6 2671     *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
 7 2672     *       the phone number originally intended to be dialed.</li>
 8 2673     * </ul>
 9 2674     * <p>Once the broadcast is finished, the resultData is used as the actual
10 2675     * number to call.  If  <code>null</code>, no call will be placed.</p>
11 2676     * <p>It is perfectly acceptable for multiple receivers to process the
12 2677     * outgoing call in turn: for example, a parental control application
13 2678     * might verify that the user is authorized to place the call at that
14 2679     * time, then a number-rewriting application might add an area code if
15 2680     * one was not specified.</p>
16 2681     * <p>For consistency, any receiver whose purpose is to prohibit phone
17 2682     * calls should have a priority of 0, to ensure it will see the final
18 2683     * phone number to be dialed.
19 2684     * Any receiver whose purpose is to rewrite phone numbers to be called
20 2685     * should have a positive priority.
21 2686     * Negative priorities are reserved for the system for this broadcast;
22 2687     * using them may cause problems.</p>
23 2688     * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
24 2689     * abort the broadcast.</p>
25 2690     * <p>Emergency calls cannot be intercepted using this mechanism, and
26 2691     * other calls cannot be modified to call emergency numbers using this
27 2692     * mechanism.
28 2693     * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
29 2694     * call to use their own service instead. Those apps should first prevent
30 2695     * the call from being placed by setting resultData to <code>null</code>
31 2696     * and then start their own app to make the call.
32 2697     * <p>You must hold the
33 2698     * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
34 2699     * permission to receive this Intent.</p>
35 2700     *
36 2701     * <p class="note">This is a protected intent that can only be sent
37 2702     * by the system.
38 2703     */
39 2704    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
40 2705    public static final String ACTION_NEW_OUTGOING_CALL =
41 2706            "android.intent.action.NEW_OUTGOING_CALL";
42 2707

ACTION_REBOOT要求設備reboot

 1 2708    /**
 2 2709     * Broadcast Action: Have the device reboot.  This is only for use by
 3 2710     * system code.
 4 2711     *
 5 2712     * <p class="note">This is a protected intent that can only be sent
 6 2713     * by the system.
 7 2714     */
 8 2715    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
 9 2716    public static final String ACTION_REBOOT =
10 2717            "android.intent.action.REBOOT";

ACTION_DOCK_EVENT代表dock狀態改變

 1 2719    /**
 2 2720     * Broadcast Action:  A sticky broadcast for changes in the physical
 3 2721     * docking state of the device.
 4 2722     *
 5 2723     * <p>The intent will have the following extra values:
 6 2724     * <ul>
 7 2725     *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
 8 2726     *       state, indicating which dock the device is physically in.</li>
 9 2727     * </ul>
10 2728     * <p>This is intended for monitoring the current physical dock state.
11 2729     * See {@link android.app.UiModeManager} for the normal API dealing with
12 2730     * dock mode changes.
13 2731     */
14 2732    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
15 2733    public static final String ACTION_DOCK_EVENT =
16 2734            "android.intent.action.DOCK_EVENT";

ACTION_IDLE_MAINTENCE_START和ACTION_IDLE_MAINTENCE_STOP代表設備不與用戶交互,能夠作耗時的動做,須要拿wakelock來保證設備不會睡眠

 1 2736    /**
 2 2737     * Broadcast Action: A broadcast when idle maintenance can be started.
 3 2738     * This means that the user is not interacting with the device and is
 4 2739     * not expected to do so soon. Typical use of the idle maintenance is
 5 2740     * to perform somehow expensive tasks that can be postponed at a moment
 6 2741     * when they will not degrade user experience.
 7 2742     * <p>
 8 2743     * <p class="note">In order to keep the device responsive in case of an
 9 2744     * unexpected user interaction, implementations of a maintenance task
10 2745     * should be interruptible. In such a scenario a broadcast with action
11 2746     * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
12 2747     * should not do the maintenance work in
13 2748     * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
14 2749     * maintenance service by {@link Context#startService(Intent)}. Also
15 2750     * you should hold a wake lock while your maintenance service is running
16 2751     * to prevent the device going to sleep.
17 2752     * </p>
18 2753     * <p>
19 2754     * <p class="note">This is a protected intent that can only be sent by
20 2755     * the system.
21 2756     * </p>
22 2757     *
23 2758     * @see #ACTION_IDLE_MAINTENANCE_END
24 2759     *
25 2760     * @hide
26 2761     */
27 2762    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
28 2763    public static final String ACTION_IDLE_MAINTENANCE_START =
29 2764            "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
30 2765
31 2766    /**
32 2767     * Broadcast Action:  A broadcast when idle maintenance should be stopped.
33 2768     * This means that the user was not interacting with the device as a result
34 2769     * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
35 2770     * was sent and now the user started interacting with the device. Typical
36 2771     * use of the idle maintenance is to perform somehow expensive tasks that
37 2772     * can be postponed at a moment when they will not degrade user experience.
38 2773     * <p>
39 2774     * <p class="note">In order to keep the device responsive in case of an
40 2775     * unexpected user interaction, implementations of a maintenance task
41 2776     * should be interruptible. Hence, on receiving a broadcast with this
42 2777     * action, the maintenance task should be interrupted as soon as possible.
43 2778     * In other words, you should not do the maintenance work in
44 2779     * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
45 2780     * maintenance service that was started on receiving of
46 2781     * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
47 2782     * lock you acquired when your maintenance service started.
48 2783     * </p>
49 2784     * <p class="note">This is a protected intent that can only be sent
50 2785     * by the system.
51 2786     *
52 2787     * @see #ACTION_IDLE_MAINTENANCE_START
53 2788     *
54 2789     * @hide
55 2790     */
56 2791    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
57 2792    public static final String ACTION_IDLE_MAINTENANCE_END =
58 2793            "android.intent.action.ACTION_IDLE_MAINTENANCE_END";

ACTION_REMOTE_INTENT代表remote intent將會發出

 1 2795    /**
 2 2796     * Broadcast Action: a remote intent is to be broadcasted.
 3 2797     *
 4 2798     * A remote intent is used for remote RPC between devices. The remote intent
 5 2799     * is serialized and sent from one device to another device. The receiving
 6 2800     * device parses the remote intent and broadcasts it. Note that anyone can
 7 2801     * broadcast a remote intent. However, if the intent receiver of the remote intent
 8 2802     * does not trust intent broadcasts from arbitrary intent senders, it should require
 9 2803     * the sender to hold certain permissions so only trusted sender's broadcast will be
10 2804     * let through.
11 2805     * @hide
12 2806     */
13 2807    public static final String ACTION_REMOTE_INTENT =
14 2808            "com.google.android.c2dm.intent.RECEIVE";
15 2809

ACTION_PRE_BOOT_COMPLETED在系統升級重啓以後發出

 1 2810    /**
 2 2811     * Broadcast Action: This is broadcast once when the user is booting after a
 3 2812     * system update. It can be used to perform cleanup or upgrades after a
 4 2813     * system update.
 5 2814     * <p>
 6 2815     * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
 7 2816     * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
 8 2817     * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
 9 2818     * sent to receivers in the system image.
10 2819     *
11 2820     * @hide
12 2821     */
13 2822    public static final String ACTION_PRE_BOOT_COMPLETED =
14 2823            "android.intent.action.PRE_BOOT_COMPLETED";

ACTION_GET_RESTRICTION_ENTRIES代表詢問app,獲取對特定用戶作權限限制的條目

 1 2810    /**
 2 2811     * Broadcast Action: This is broadcast once when the user is booting after a
 3 2812     * system update. It can be used to perform cleanup or upgrades after a
 4 2813     * system update.
 5 2814     * <p>
 6 2815     * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
 7 2816     * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
 8 2817     * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
 9 2818     * sent to receivers in the system image.
10 2819     *
11 2820     * @hide
12 2821     */
13 2822    public static final String ACTION_PRE_BOOT_COMPLETED =
14 2823            "android.intent.action.PRE_BOOT_COMPLETED";

ACTION_USER_INITIALIZE代表新用戶第一次被啓動,通知系統app;ACTION_USER_FOREGROUND代表用戶被切換到前臺,ACTION_USER_BACKGROUND代表用戶被切換到後臺;ACTION_USER_ADD代表user被添加進來;ACTION_USER_STARTED代表user被啓動了;ACTION_USER_STARTING代表user正在被啓動;ACTION_USER_STOPPING表面那個user正在被中止;ACTION_USER_STOPPED代表user被中止了;ACTION_USER_REMOVED代表用戶被移除;ACTION_USER_SWITCHED代表user被切換;ACTION_USER_UNLOCKED代表存儲分區被解鎖;ACTION_USER_INFO_CHANGED代表user信息改變

  1 2842    /**
  2 2843     * Sent the first time a user is starting, to allow system apps to
  3 2844     * perform one time initialization.  (This will not be seen by third
  4 2845     * party applications because a newly initialized user does not have any
  5 2846     * third party applications installed for it.)  This is sent early in
  6 2847     * starting the user, around the time the home app is started, before
  7 2848     * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
  8 2849     * broadcast, since it is part of a visible user interaction; be as quick
  9 2850     * as possible when handling it.
 10 2851     */
 11 2852    public static final String ACTION_USER_INITIALIZE =
 12 2853            "android.intent.action.USER_INITIALIZE";
 13 2854
 14 2855    /**
 15 2856     * Sent when a user switch is happening, causing the process's user to be
 16 2857     * brought to the foreground.  This is only sent to receivers registered
 17 2858     * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
 18 2859     * Context.registerReceiver}.  It is sent to the user that is going to the
 19 2860     * foreground.  This is sent as a foreground
 20 2861     * broadcast, since it is part of a visible user interaction; be as quick
 21 2862     * as possible when handling it.
 22 2863     */
 23 2864    public static final String ACTION_USER_FOREGROUND =
 24 2865            "android.intent.action.USER_FOREGROUND";
 25 2866
 26 2867    /**
 27 2868     * Sent when a user switch is happening, causing the process's user to be
 28 2869     * sent to the background.  This is only sent to receivers registered
 29 2870     * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
 30 2871     * Context.registerReceiver}.  It is sent to the user that is going to the
 31 2872     * background.  This is sent as a foreground
 32 2873     * broadcast, since it is part of a visible user interaction; be as quick
 33 2874     * as possible when handling it.
 34 2875     */
 35 2876    public static final String ACTION_USER_BACKGROUND =
 36 2877            "android.intent.action.USER_BACKGROUND";
 37 2878
 38 2879    /**
 39 2880     * Broadcast sent to the system when a user is added. Carries an extra
 40 2881     * EXTRA_USER_HANDLE that has the userHandle of the new user.  It is sent to
 41 2882     * all running users.  You must hold
 42 2883     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
 43 2884     * @hide
 44 2885     */
 45 2886    public static final String ACTION_USER_ADDED =
 46 2887            "android.intent.action.USER_ADDED";
 47 2888
 48 2889    /**
 49 2890     * Broadcast sent by the system when a user is started. Carries an extra
 50 2891     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only sent to
 51 2892     * registered receivers, not manifest receivers.  It is sent to the user
 52 2893     * that has been started.  This is sent as a foreground
 53 2894     * broadcast, since it is part of a visible user interaction; be as quick
 54 2895     * as possible when handling it.
 55 2896     * @hide
 56 2897     */
 57 2898    public static final String ACTION_USER_STARTED =
 58 2899            "android.intent.action.USER_STARTED";
 59 2900
 60 2901    /**
 61 2902     * Broadcast sent when a user is in the process of starting.  Carries an extra
 62 2903     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
 63 2904     * sent to registered receivers, not manifest receivers.  It is sent to all
 64 2905     * users (including the one that is being started).  You must hold
 65 2906     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
 66 2907     * this broadcast.  This is sent as a background broadcast, since
 67 2908     * its result is not part of the primary UX flow; to safely keep track of
 68 2909     * started/stopped state of a user you can use this in conjunction with
 69 2910     * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
 70 2911     * other user state broadcasts since those are foreground broadcasts so can
 71 2912     * execute in a different order.
 72 2913     * @hide
 73 2914     */
 74 2915    public static final String ACTION_USER_STARTING =
 75 2916            "android.intent.action.USER_STARTING";
 76 2917
 77 2918    /**
 78 2919     * Broadcast sent when a user is going to be stopped.  Carries an extra
 79 2920     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
 80 2921     * sent to registered receivers, not manifest receivers.  It is sent to all
 81 2922     * users (including the one that is being stopped).  You must hold
 82 2923     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
 83 2924     * this broadcast.  The user will not stop until all receivers have
 84 2925     * handled the broadcast.  This is sent as a background broadcast, since
 85 2926     * its result is not part of the primary UX flow; to safely keep track of
 86 2927     * started/stopped state of a user you can use this in conjunction with
 87 2928     * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
 88 2929     * other user state broadcasts since those are foreground broadcasts so can
 89 2930     * execute in a different order.
 90 2931     * @hide
 91 2932     */
 92 2933    public static final String ACTION_USER_STOPPING =
 93 2934            "android.intent.action.USER_STOPPING";
 94 2935
 95 2936    /**
 96 2937     * Broadcast sent to the system when a user is stopped. Carries an extra
 97 2938     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is similar to
 98 2939     * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
 99 2940     * specific package.  This is only sent to registered receivers, not manifest
100 2941     * receivers.  It is sent to all running users <em>except</em> the one that
101 2942     * has just been stopped (which is no longer running).
102 2943     * @hide
103 2944     */
104 2945    public static final String ACTION_USER_STOPPED =
105 2946            "android.intent.action.USER_STOPPED";
106 2947
107 2948    /**
108 2949     * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
109 2950     * the userHandle of the user.  It is sent to all running users except the
110 2951     * one that has been removed. The user will not be completely removed until all receivers have
111 2952     * handled the broadcast. You must hold
112 2953     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
113 2954     * @hide
114 2955     */
115 2956    public static final String ACTION_USER_REMOVED =
116 2957            "android.intent.action.USER_REMOVED";
117 2958
118 2959    /**
119 2960     * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
120 2961     * the userHandle of the user to become the current one. This is only sent to
121 2962     * registered receivers, not manifest receivers.  It is sent to all running users.
122 2963     * You must hold
123 2964     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
124 2965     * @hide
125 2966     */
126 2967    public static final String ACTION_USER_SWITCHED =
127 2968            "android.intent.action.USER_SWITCHED";
128 2969
129 2970    /**
130 2971     * Broadcast Action: Sent when the credential-encrypted private storage has
131 2972     * become unlocked for the target user. This is only sent to registered
132 2973     * receivers, not manifest receivers.
133 2974     */
134 2975    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
135 2976    public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
136 2977
137 2978    /**
138 2979     * Broadcast sent to the system when a user's information changes. Carries an extra
139 2980     * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
140 2981     * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
141 2982     * @hide
142 2983     */
143 2984    public static final String ACTION_USER_INFO_CHANGED =
144 2985            "android.intent.action.USER_INFO_CHANGED";

ACTION_MANAGED_PROFILE_ADDED代表被管理的用戶配置被添加;ACTION_MANAGED_PROFILE_REMOVED代表被管理的用戶配置被移除;ACTION_MANAGED_PROFILE_UNLOCKED代表相關用戶配置的存儲分區被解鎖;ACTION_MANAGED_PROFILE_AVAILABLE代表相關用戶配置可用;ACTION_MANAGED_PROFILE_UNAVAILABLE代表相關用戶配置不可用

 1 3019    /**
 2 3020     * Broadcast sent to the primary user when an associated managed profile has become available.
 3 3021     * Currently this includes when the user disables quiet mode for the profile. Carries an extra
 4 3022     * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
 5 3023     * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
 6 3024     * of quiet mode. This is only sent to registered receivers, not manifest receivers.
 7 3025     */
 8 3026    public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
 9 3027            "android.intent.action.MANAGED_PROFILE_AVAILABLE";
10 3028
11 3029    /**
12 3030     * Broadcast sent to the primary user when an associated managed profile has become unavailable.
13 3031     * Currently this includes when the user enables quiet mode for the profile. Carries an extra
14 3032     * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
15 3033     * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
16 3034     * of quiet mode. This is only sent to registered receivers, not manifest receivers.
17 3035     */
18 3036    public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
19 3037            "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";

ACTION_QUICK_CLOCK代表選擇了快速clock widget

1 3039    /**
2 3040     * Sent when the user taps on the clock widget in the system's "quick settings" area.
3 3041     */
4 3042    public static final String ACTION_QUICK_CLOCK =
5 3043            "android.intent.action.QUICK_CLOCK";
6 3044

ACTION_SHOW_BRIGHTNESS_DIALOG顯示亮度調節對話框

1 3039    /**
2 3040     * Sent when the user taps on the clock widget in the system's "quick settings" area.
3 3041     */
4 3042    public static final String ACTION_QUICK_CLOCK =
5 3043            "android.intent.action.QUICK_CLOCK";
6 3044

ACTION_GLOBAL_BUTTON代表一個全局button被按到

1 3052    /**
2 3053     * Broadcast Action:  A global button was pressed.  Includes a single
3 3054     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
4 3055     * caused the broadcast.
5 3056     * @hide
6 3057     */
7 3058    public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";

ACTION_MEDIA_RESOURCE_GRANTED代表媒體資源被某個package獲取到

 1 3060    /**
 2 3061     * Broadcast Action: Sent when media resource is granted.
 3 3062     * <p>
 4 3063     * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
 5 3064     * granted.
 6 3065     * </p>
 7 3066     * <p class="note">
 8 3067     * This is a protected intent that can only be sent by the system.
 9 3068     * </p>
10 3069     * <p class="note">
11 3070     * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
12 3071     * </p>
13 3072     *
14 3073     * @hide
15 3074     */
16 3075    public static final String ACTION_MEDIA_RESOURCE_GRANTED =
17 3076            "android.intent.action.MEDIA_RESOURCE_GRANTED";

ACTION_OPEN_DOCUMENT代表容許用戶選擇並獲取一個或多個文件;ACTION_CREATE_DOCUMENT代表建立一個文件

 1 3078    /**
 2 3079     * Activity Action: Allow the user to select and return one or more existing
 3 3080     * documents. When invoked, the system will display the various
 4 3081     * {@link DocumentsProvider} instances installed on the device, letting the
 5 3082     * user interactively navigate through them. These documents include local
 6 3083     * media, such as photos and video, and documents provided by installed
 7 3084     * cloud storage providers.
 8 3085     * <p>
 9 3086     * Each document is represented as a {@code content://} URI backed by a
10 3087     * {@link DocumentsProvider}, which can be opened as a stream with
11 3088     * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
12 3089     * {@link android.provider.DocumentsContract.Document} metadata.
13 3090     * <p>
14 3091     * All selected documents are returned to the calling application with
15 3092     * persistable read and write permission grants. If you want to maintain
16 3093     * access to the documents across device reboots, you need to explicitly
17 3094     * take the persistable permissions using
18 3095     * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
19 3096     * <p>
20 3097     * Callers must indicate the acceptable document MIME types through
21 3098     * {@link #setType(String)}. For example, to select photos, use
22 3099     * {@code image/*}. If multiple disjoint MIME types are acceptable, define
23 3100     * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
24 3101     * {@literal *}/*.
25 3102     * <p>
26 3103     * If the caller can handle multiple returned items (the user performing
27 3104     * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
28 3105     * to indicate this.
29 3106     * <p>
30 3107     * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
31 3108     * URIs that can be opened with
32 3109     * {@link ContentResolver#openFileDescriptor(Uri, String)}.
33 3110     * <p>
34 3111     * Output: The URI of the item that was picked, returned in
35 3112     * {@link #getData()}. This must be a {@code content://} URI so that any
36 3113     * receiver can access it. If multiple documents were selected, they are
37 3114     * returned in {@link #getClipData()}.
38 3115     *
39 3116     * @see DocumentsContract
40 3117     * @see #ACTION_OPEN_DOCUMENT_TREE
41 3118     * @see #ACTION_CREATE_DOCUMENT
42 3119     * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
43 3120     */
44 3121    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
45 3122    public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
46 3123
47 3124    /**
48 3125     * Activity Action: Allow the user to create a new document. When invoked,
49 3126     * the system will display the various {@link DocumentsProvider} instances
50 3127     * installed on the device, letting the user navigate through them. The
51 3128     * returned document may be a newly created document with no content, or it
52 3129     * may be an existing document with the requested MIME type.
53 3130     * <p>
54 3131     * Each document is represented as a {@code content://} URI backed by a
55 3132     * {@link DocumentsProvider}, which can be opened as a stream with
56 3133     * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
57 3134     * {@link android.provider.DocumentsContract.Document} metadata.
58 3135     * <p>
59 3136     * Callers must indicate the concrete MIME type of the document being
60 3137     * created by setting {@link #setType(String)}. This MIME type cannot be
61 3138     * changed after the document is created.
62 3139     * <p>
63 3140     * Callers can provide an initial display name through {@link #EXTRA_TITLE},
64 3141     * but the user may change this value before creating the file.
65 3142     * <p>
66 3143     * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
67 3144     * URIs that can be opened with
68 3145     * {@link ContentResolver#openFileDescriptor(Uri, String)}.
69 3146     * <p>
70 3147     * Output: The URI of the item that was created. This must be a
71 3148     * {@code content://} URI so that any receiver can access it.
72 3149     *
73 3150     * @see DocumentsContract
74 3151     * @see #ACTION_OPEN_DOCUMENT
75 3152     * @see #ACTION_OPEN_DOCUMENT_TREE
76 3153     * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
77 3154     */
78 3155    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
79 3156    public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";

ACTION_OPEN_DOCUMENT_TREE代表開打一個文檔子樹

 1 3158    /**
 2 3159     * Activity Action: Allow the user to pick a directory subtree. When
 3 3160     * invoked, the system will display the various {@link DocumentsProvider}
 4 3161     * instances installed on the device, letting the user navigate through
 5 3162     * them. Apps can fully manage documents within the returned directory.
 6 3163     * <p>
 7 3164     * To gain access to descendant (child, grandchild, etc) documents, use
 8 3165     * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
 9 3166     * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
10 3167     * with the returned URI.
11 3168     * <p>
12 3169     * Output: The URI representing the selected directory tree.
13 3170     *
14 3171     * @see DocumentsContract
15 3172     */
16 3173    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
17 3174    public static final String
18 3175            ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";

ACTION_DYNAMIC_SENSOR_CHANGED代表sensor鏈接或者斷開鏈接

 1 3177    /**
 2 3178     * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
 3 3179     * exisiting sensor being disconnected.
 4 3180     *
 5 3181     * <p class="note">This is a protected intent that can only be sent by the system.</p>
 6 3182     *
 7 3183     * {@hide}
 8 3184     */
 9 3185    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
10 3186    public static final String
11 3187            ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";

ACTION_MASTER_CLEAR是hide的,不導入sdk裏,代表是否作factory reset

1 3189    /** {@hide} */
2 3190    public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";

EXTRA_FORCE_MASTER_CLEAR代表是否強制作factory reset

1 3192    /**
2 3193     * Boolean intent extra to be used with {@link ACTION_MASTER_CLEAR} in order to force a factory
3 3194     * reset even if {@link android.os.UserManager.DISALLOW_FACTORY_RESET} is set.
4 3195     * @hide
5 3196     */
6 3197    public static final String EXTRA_FORCE_MASTER_CLEAR =
7 3198            "android.intent.extra.FORCE_MASTER_CLEAR";
8 3199

ACTION_SETTING_RESTORED代表一個設置項正從備份裏還原,EXTRA_SETTING_NAME代表設置項的名字,EXTRA_SETTING_PREVIOUS_VALUE代表該項之前的值,EXTRA_SETTING_NEW_VALUE代表新的值

 1 3200    /**
 2 3201     * Broadcast action: report that a settings element is being restored from backup.  The intent
 3 3202     * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
 4 3203     * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
 5 3204     * is the value of that settings entry prior to the restore operation.  All of these values are
 6 3205     * represented as strings.
 7 3206     *
 8 3207     * <p>This broadcast is sent only for settings provider entries known to require special handling
 9 3208     * around restore time.  These entries are found in the BROADCAST_ON_RESTORE table within
10 3209     * the provider's backup agent implementation.
11 3210     *
12 3211     * @see #EXTRA_SETTING_NAME
13 3212     * @see #EXTRA_SETTING_PREVIOUS_VALUE
14 3213     * @see #EXTRA_SETTING_NEW_VALUE
15 3214     * {@hide}
16 3215     */
17 3216    public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
18 3217
19 3218    /** {@hide} */
20 3219    public static final String EXTRA_SETTING_NAME = "setting_name";
21 3220    /** {@hide} */
22 3221    public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
23 3222    /** {@hide} */
24 3223    public static final String EXTRA_SETTING_NEW_VALUE = "new_value";

ACTION_PROCESS代表處理一個文本;EXTRA_PROCESS_TEXT是要處理的text,EXTRA_PROCESS_TEXT_READONLY代表返回的處理過的text是不是隻讀的

 1 3225    /**
 2 3226     * Activity Action: Process a piece of text.
 3 3227     * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
 4 3228     * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
 5 3229     * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
 6 3230     */
 7 3231    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
 8 3232    public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
 9 3233    /**
10 3234     * The name of the extra used to define the text to be processed, as a
11 3235     * CharSequence. Note that this may be a styled CharSequence, so you must use
12 3236     * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
13 3237     */
14 3238    public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
15 3239    /**
16 3240     * The name of the boolean extra used to define if the processed text will be used as read-only.
17 3241     */
18 3242    public static final String EXTRA_PROCESS_TEXT_READONLY =

ACTION_THERMAL_EVENT代表達到了某個溫度的事件發生;EXTRA_THERMAL_STATE是溫度的狀態,是EXTRA_THERMAL_STATE_NORMAL,EXTRA_THERMAL_STATE_WARNING,EXTRA_THERMAL_STATE_EXCEEDED中的一個

 1 3245    /**
 2 3246     * Broadcast action: reports when a new thermal event has been reached. When the device
 3 3247     * is reaching its maximum temperatue, the thermal level reported
 4 3248     * {@hide}
 5 3249     */
 6 3250    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
 7 3251    public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
 8 3252
 9 3253    /** {@hide} */
10 3254    public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
11 3255
12 3256    /**
13 3257     * Thermal state when the device is normal. This state is sent in the
14 3258     * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
15 3259     * {@hide}
16 3260     */
17 3261    public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
18 3262
19 3263    /**
20 3264     * Thermal state where the device is approaching its maximum threshold. This state is sent in
21 3265     * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
22 3266     * {@hide}
23 3267     */
24 3268    public static final int EXTRA_THERMAL_STATE_WARNING = 1;
25 3269
26 3270    /**
27 3271     * Thermal state where the device has reached its maximum threshold. This state is sent in the
28 3272     * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
29 3273     * {@hide}
30 3274     */
31 3275    public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;

 

下面開始講Intent category

CATEGORY_DEFAULT代表是否該activity應該成爲操做數據動做的默認操做者,若是其餘activity沒有設置這個,那麼將對用戶展現設置了這個的activity

 1 3278    // ---------------------------------------------------------------------
 2 3279    // ---------------------------------------------------------------------
 3 3280    // Standard intent categories (see addCategory()).
 4 3281
 5 3282    /**
 6 3283     * Set if the activity should be an option for the default action
 7 3284     * (center press) to perform on a piece of data.  Setting this will
 8 3285     * hide from the user any activities without it set when performing an
 9 3286     * action on some data.  Note that this is normally -not- set in the
10 3287     * Intent when initiating an action -- it is for use in intent filters
11 3288     * specified in packages.
12 3289     */
13 3290    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
14 3291    public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";

CATEGORY_BROWSABLE代表Activity能夠被瀏覽器調用

 1 3292    /**
 2 3293     * Activities that can be safely invoked from a browser must support this
 3 3294     * category.  For example, if the user is viewing a web page or an e-mail
 4 3295     * and clicks on a link in the text, the Intent generated execute that
 5 3296     * link will require the BROWSABLE category, so that only activities
 6 3297     * supporting this category will be considered as possible actions.  By
 7 3298     * supporting this category, you are promising that there is nothing
 8 3299     * damaging (without user intervention) that can happen by invoking any
 9 3300     * matching Intent.
10 3301     */
11 3302    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
12 3303    public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";

CATEGORY_VOICE代表Activity會參與語音交互

1 3304    /**
2 3305     * Categories for activities that can participate in voice interaction.
3 3306     * An activity that supports this category must be prepared to run with
4 3307     * no UI shown at all (though in some case it may have a UI shown), and
5 3308     * rely on {@link android.app.VoiceInteractor} to interact with the user.
6 3309     */
7 3310    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
8 3311    public static final String CATEGORY_VOICE = "android.intent.category.VOICE";

CATEGORY_ALTERNATIVE代表Activity是正在view的data的一個可替換選項

 1 3312    /**
 2 3313     * Set if the activity should be considered as an alternative action to
 3 3314     * the data the user is currently viewing.  See also
 4 3315     * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
 5 3316     * applies to the selection in a list of items.
 6 3317     *
 7 3318     * <p>Supporting this category means that you would like your activity to be
 8 3319     * displayed in the set of alternative things the user can do, usually as
 9 3320     * part of the current activity's options menu.  You will usually want to
10 3321     * include a specific label in the &lt;intent-filter&gt; of this action
11 3322     * describing to the user what it does.
12 3323     *
13 3324     * <p>The action of IntentFilter with this category is important in that it
14 3325     * describes the specific action the target will perform.  This generally
15 3326     * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
16 3327     * a specific name such as "com.android.camera.action.CROP.  Only one
17 3328     * alternative of any particular action will be shown to the user, so using
18 3329     * a specific action like this makes sure that your alternative will be
19 3330     * displayed while also allowing other applications to provide their own
20 3331     * overrides of that particular action.
21 3332     */
22 3333    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
23 3334    public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";

CATEGORY_SELECTED_ALTERNATIVE代表被選中的數據的可替代選擇操做

1 3335    /**
2 3336     * Set if the activity should be considered as an alternative selection
3 3337     * action to the data the user has currently selected.  This is like
4 3338     * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
5 3339     * of items from which the user can select, giving them alternatives to the
6 3340     * default action that will be performed on it.
7 3341     */
8 3342    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
9 3343    public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";

CATEGORY_TAB代表Activityi作爲一個Tab被包含在TabActivity裏

1 3344    /**
2 3345     * Intended to be used as a tab inside of a containing TabActivity.
3 3346     */
4 3347    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3348    public static final String CATEGORY_TAB = "android.intent.category.TAB";

CATEGORY_LAUNCHER代表Activity應該顯示在launcher界面

1 3349    /**
2 3350     * Should be displayed in the top-level launcher.
3 3351     */
4 3352    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3353    public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";

CATEGORY_LEANBACK_LAUNCHER代表Activity顯示在Leanback launcher界面

1 3354    /**
2 3355     * Indicates an activity optimized for Leanback mode, and that should
3 3356     * be displayed in the Leanback launcher.
4 3357     */
5 3358    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
6 3359    public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";

CATEGORY_LEANBACK_SETTINGS代表Activity爲leanback settings activity

1 3360    /**
2 3361     * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3 3362     * @hide
4 3363     */
5 3364    @SystemApi
6 3365    public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";

CATEGORY_INFO代表包含package info的Activity

1 3366    /**
2 3367     * Provides information about the package it is in; typically used if
3 3368     * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4 3369     * a front-door to the user without having to be shown in the all apps list.
5 3370     */
6 3371    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
7 3372    public static final String CATEGORY_INFO = "android.intent.category.INFO";

CATEGORY_HOME代表爲home Activty,在第一次啓動的時候顯示,即歡迎啓動界面

1 3373    /**
2 3374     * This is the home activity, that is the first activity that is displayed
3 3375     * when the device boots.
4 3376     */
5 3377    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
6 3378    public static final String CATEGORY_HOME = "android.intent.category.HOME";

CATEGORY_HOME_MAIN代表Activity在設備作完設置後顯示

1 3379    /**
2 3380     * This is the home activity that is displayed when the device is finished setting up and ready
3 3381     * for use.
4 3382     * @hide
5 3383     */
6 3384    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
7 3385    public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";

CATEGORY_SETUP_WIZARD代表爲設置嚮導Activity

1 3386    /**
2 3387     * This is the setup wizard activity, that is the first activity that is displayed
3 3388     * when the user sets up the device for the first time.
4 3389     * @hide
5 3390     */
6 3391    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
7 3392    public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";

CATEGORY_PREFERENCE代表該Activity爲偏好面板

1 3393    /**
2 3394     * This activity is a preference panel.
3 3395     */
4 3396    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3397    public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";

CATEGORY_DEVELOPMENT_PREFERENCE代表該Activity爲開發偏好面板

1 3398    /**
2 3399     * This activity is a development preference panel.
3 3400     */
4 3401    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3402    public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
6 3403    /**

CATEGORY_EMBED代表該Activity能夠嵌進父Activity裏

1 3403    /**
2 3404     * Capable of running inside a parent activity container.
3 3405     */
4 3406    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3407    public static final String CATEGORY_EMBED = "android.intent.category.EMBED";

CATEGORY_APP_MARKET代表該Activity能夠瀏覽和下載應用程序

1 3408    /**
2 3409     * This activity allows the user to browse and download new applications.
3 3410     */
4 3411    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3412    public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";

CATEGORY_MONKEY代表該Activity能夠被Monkey或者其餘自動測試工具使用

1 3413    /**
2 3414     * This activity may be exercised by the monkey or other automated test tools.
3 3415     */
4 3416    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5 3417    public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";

CATEGORY_TEST代表該Activity僅僅是作測試用

1 3418    /**
2 3419     * To be used as a test (not part of the normal user experience).
3 3420     */
4 3421    public static final String CATEGORY_TEST = "android.intent.category.TEST";

CATEGORY_UNIT_TEST代表Activity用來作單元測試

1 3422    /**
2 3423     * To be used as a unit test (run through the Test Harness).
3 3424     */
4 3425    public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";

CATEGORY_SAMPLE_CODE代表Activity用來作例子

1 3426    /**
2 3427     * To be used as a sample code example (not part of the normal user
3 3428     * experience).
4 3429     */
5 3430    public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";

CATEGORY_OPENABLE代表數據的URI能夠用ContentResolver#OpenFileDescriptor來處理

 1 3432    /**
 2 3433     * Used to indicate that an intent only wants URIs that can be opened with
 3 3434     * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
 4 3435     * must support at least the columns defined in {@link OpenableColumns} when
 5 3436     * queried.
 6 3437     *
 7 3438     * @see #ACTION_GET_CONTENT
 8 3439     * @see #ACTION_OPEN_DOCUMENT
 9 3440     * @see #ACTION_CREATE_DOCUMENT
10 3441     */
11 3442    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
12 3443    public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";

CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST代表Activity作framework  instrumentation測試

1 3445    /**
2 3446     * To be used as code under test for framework instrumentation tests.
3 3447     */
4 3448    public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
5 3449            "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";

CATEGORY_CAR_DOCK代表Activity用於汽車docker;CATEGORY_DESK_DOCKER代表用於桌面docker;CATEGORY_LE_DESK_DOCKER代表用於low end桌面docker;CATEGORY_HE_DESK_DOCKER代表用於high end桌面docker;CATEGORY_CAR_MODE代表是在car模式下

 1 3450    /**
 2 3451     * An activity to run when device is inserted into a car dock.
 3 3452     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
 4 3453     * information, see {@link android.app.UiModeManager}.
 5 3454     */
 6 3455    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 7 3456    public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
 8 3457    /**
 9 3458     * An activity to run when device is inserted into a car dock.
10 3459     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
11 3460     * information, see {@link android.app.UiModeManager}.
12 3461     */
13 3462    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
14 3463    public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
15 3464    /**
16 3465     * An activity to run when device is inserted into a analog (low end) dock.
17 3466     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
18 3467     * information, see {@link android.app.UiModeManager}.
19 3468     */
20 3469    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
21 3470    public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
22 3471
23 3472    /**
24 3473     * An activity to run when device is inserted into a digital (high end) dock.
25 3474     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
26 3475     * information, see {@link android.app.UiModeManager}.
27 3476     */
28 3477    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
29 3478    public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
30 3479
31 3480    /**
32 3481     * Used to indicate that the activity can be used in a car environment.
33 3482     */
34 3483    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
35 3484    public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";

CATEGORY_APP_BROWSER代表啓動一個瀏覽器;CATEGORY_APP_CALCULATOR代表啓動一個計算器;CATEGORY_APP_CALENDAR代表啓動一個日曆;CATEGORY_APP_CONTACTS代表啓動一個聯繫人;CATEGORY_APP_EMAIL啓動電子郵件;CATEGORY_APP_GALLEY啓動相冊;CATEGORY_APP_MAPS代表啓動地圖;CATEGORY_APP_MESSAGING代表啓動短信;CATEGORY_APP_MUSIC代表啓動音樂播放器

  1 3486    // ---------------------------------------------------------------------
  2 3487    // ---------------------------------------------------------------------
  3 3488    // Application launch intent categories (see addCategory()).
  4 3489
  5 3490    /**
  6 3491     * Used with {@link #ACTION_MAIN} to launch the browser application.
  7 3492     * The activity should be able to browse the Internet.
  8 3493     * <p>NOTE: This should not be used as the primary key of an Intent,
  9 3494     * since it will not result in the app launching with the correct
 10 3495     * action and category.  Instead, use this with
 11 3496     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 12 3497     * Intent with this category in the selector.</p>
 13 3498     */
 14 3499    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 15 3500    public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
 16 3501
 17 3502    /**
 18 3503     * Used with {@link #ACTION_MAIN} to launch the calculator application.
 19 3504     * The activity should be able to perform standard arithmetic operations.
 20 3505     * <p>NOTE: This should not be used as the primary key of an Intent,
 21 3506     * since it will not result in the app launching with the correct
 22 3507     * action and category.  Instead, use this with
 23 3508     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 24 3509     * Intent with this category in the selector.</p>
 25 3510     */
 26 3511    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 27 3512    public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
 28 3513
 29 3514    /**
 30 3515     * Used with {@link #ACTION_MAIN} to launch the calendar application.
 31 3516     * The activity should be able to view and manipulate calendar entries.
 32 3517     * <p>NOTE: This should not be used as the primary key of an Intent,
 33 3518     * since it will not result in the app launching with the correct
 34 3519     * action and category.  Instead, use this with
 35 3520     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 36 3521     * Intent with this category in the selector.</p>
 37 3522     */
 38 3523    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 39 3524    public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
 40 3525
 41 3526    /**
 42 3527     * Used with {@link #ACTION_MAIN} to launch the contacts application.
 43 3528     * The activity should be able to view and manipulate address book entries.
 44 3529     * <p>NOTE: This should not be used as the primary key of an Intent,
 45 3530     * since it will not result in the app launching with the correct
 46 3531     * action and category.  Instead, use this with
 47 3532     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 48 3533     * Intent with this category in the selector.</p>
 49 3534     */
 50 3535    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 51 3536    public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
 52 3537
 53 3538    /**
 54 3539     * Used with {@link #ACTION_MAIN} to launch the email application.
 55 3540     * The activity should be able to send and receive email.
 56 3541     * <p>NOTE: This should not be used as the primary key of an Intent,
 57 3542     * since it will not result in the app launching with the correct
 58 3543     * action and category.  Instead, use this with
 59 3544     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 60 3545     * Intent with this category in the selector.</p>
 61 3546     */
 62 3547    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 63 3548    public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
 64 3549
 65 3550    /**
 66 3551     * Used with {@link #ACTION_MAIN} to launch the gallery application.
 67 3552     * The activity should be able to view and manipulate image and video files
 68 3553     * stored on the device.
 69 3554     * <p>NOTE: This should not be used as the primary key of an Intent,
 70 3555     * since it will not result in the app launching with the correct
 71 3556     * action and category.  Instead, use this with
 72 3557     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 73 3558     * Intent with this category in the selector.</p>
 74 3559     */
 75 3560    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 76 3561    public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
 77 3562
 78 3563    /**
 79 3564     * Used with {@link #ACTION_MAIN} to launch the maps application.
 80 3565     * The activity should be able to show the user's current location and surroundings.
 81 3566     * <p>NOTE: This should not be used as the primary key of an Intent,
 82 3567     * since it will not result in the app launching with the correct
 83 3568     * action and category.  Instead, use this with
 84 3569     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 85 3570     * Intent with this category in the selector.</p>
 86 3571     */
 87 3572    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
 88 3573    public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
 89 3574
 90 3575    /**
 91 3576     * Used with {@link #ACTION_MAIN} to launch the messaging application.
 92 3577     * The activity should be able to send and receive text messages.
 93 3578     * <p>NOTE: This should not be used as the primary key of an Intent,
 94 3579     * since it will not result in the app launching with the correct
 95 3580     * action and category.  Instead, use this with
 96 3581     * {@link #makeMainSelectorActivity(String, String)} to generate a main
 97 3582     * Intent with this category in the selector.</p>
 98 3583     */
 99 3584    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
100 3585    public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
101 3586
102 3587    /**
103 3588     * Used with {@link #ACTION_MAIN} to launch the music application.
104 3589     * The activity should be able to play, browse, or manipulate music files
105 3590     * stored on the device.
106 3591     * <p>NOTE: This should not be used as the primary key of an Intent,
107 3592     * since it will not result in the app launching with the correct
108 3593     * action and category.  Instead, use this with
109 3594     * {@link #makeMainSelectorActivity(String, String)} to generate a main
110 3595     * Intent with this category in the selector.</p>
111 3596     */
112 3597    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
113 3598    public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";

 

下面爲標準的extra 數據key

EXTRA_TEMPLATE代表要建立記錄的初始值,用在ACTION_INSERT

 1 3600    // ---------------------------------------------------------------------
 2 3601    // ---------------------------------------------------------------------
 3 3602    // Standard extra data keys.
 4 3603
 5 3604    /**
 6 3605     * The initial data to place in a newly created record.  Use with
 7 3606     * {@link #ACTION_INSERT}.  The data here is a Map containing the same
 8 3607     * fields as would be given to the underlying ContentProvider.insert()
 9 3608     * call.
10 3609     */
11 3610    public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";

 EXTRA_TEXT和ACTION_SEND一塊兒用,代表要發送的字符串

1 3612    /**
2 3613     * A constant CharSequence that is associated with the Intent, used with
3 3614     * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
4 3615     * this may be a styled CharSequence, so you must use
5 3616     * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
6 3617     * retrieve it.
7 3618     */
8 3619    public static final String EXTRA_TEXT = "android.intent.extra.TEXT";

EXTRA_HTML_TEXT和ACTION_SEND一塊兒用,代表要發表的html字符串

1 3621    /**
2 3622     * A constant String that is associated with the Intent, used with
3 3623     * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4 3624     * as HTML formatted text.  Note that you <em>must</em> also supply
5 3625     * {@link #EXTRA_TEXT}.
6 3626     */
7 3627    public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";

EXTRA_STREAM代表要發送的流數據URI

1 3629    /**
2 3630     * A content: URI holding a stream of data associated with the Intent,
3 3631     * used with {@link #ACTION_SEND} to supply the data being sent.
4 3632     */
5 3633    public static final String EXTRA_STREAM = "android.intent.extra.STREAM";

EXTRA_EMAIL代表要發送的email的地址

1 3635    /**
2 3636     * A String[] holding e-mail addresses that should be delivered to.
3 3637     */
4 3638    public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";

EXTRA_CC代表email cc的地址

1 3640    /**
2 3641     * A String[] holding e-mail addresses that should be carbon copied.
3 3642     */
4 3643    public static final String EXTRA_CC       = "android.intent.extra.CC";

EXTRA_BCC代表email bcc的地址

1 3645    /**
2 3646     * A String[] holding e-mail addresses that should be blind carbon copied.
3 3647     */
4 3648    public static final String EXTRA_BCC      = "android.intent.extra.BCC";

EXTRA_SUBJECT代表email的主題

1 3650    /**
2 3651     * A constant string holding the desired subject line of a message.
3 3652     */
4 3653    public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";

EXTRA_INTENT包含Intent的表述字符

1 3655    /**
2 3656     * An Intent describing the choices you would like shown with
3 3657     * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
4 3658     */
5 3659    public static final String EXTRA_INTENT = "android.intent.extra.INTENT";

EXTRA_USER_ID代表要用的user id

1 3661    /**
2 3662     * An int representing the user id to be used.
3 3663     *
4 3664     * @hide
5 3665     */
6 3666    public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";

EXTRA_TASK_ID代表要用的task id

1 3668    /**
2 3669     * An int representing the task id to be retrieved. This is used when a launch from recents is
3 3670     * intercepted by another action such as credentials confirmation to remember which task should
4 3671     * be resumed when complete.
5 3672     *
6 3673     * @hide
7 3674     */
8 3675    public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
9 3676

EXTRA_ALTERNATIVE_INTENTS代表ACTION_CHOOSER將要展現的可選擇Intent

 1 3677    /**
 2 3678     * An Intent[] describing additional, alternate choices you would like shown with
 3 3679     * {@link #ACTION_CHOOSER}.
 4 3680     *
 5 3681     * <p>An app may be capable of providing several different payload types to complete a
 6 3682     * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
 7 3683     * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
 8 3684     * several different supported sending mechanisms for sharing, such as the actual "image/*"
 9 3685     * photo data or a hosted link where the photos can be viewed.</p>
10 3686     *
11 3687     * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
12 3688     * first/primary/preferred intent in the set. Additional intents specified in
13 3689     * this extra are ordered; by default intents that appear earlier in the array will be
14 3690     * preferred over intents that appear later in the array as matches for the same
15 3691     * target component. To alter this preference, a calling app may also supply
16 3692     * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
17 3693     */
18 3694    public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";

 EXTRA_EXCLUDE_COMPONENTS代表要排除給用戶的組件名稱。

 1 3696    /**
 2 3697     * A {@link ComponentName ComponentName[]} describing components that should be filtered out
 3 3698     * and omitted from a list of components presented to the user.
 4 3699     *
 5 3700     * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
 6 3701     * in this array if it otherwise would have shown them. Useful for omitting specific targets
 7 3702     * from your own package or other apps from your organization if the idea of sending to those
 8 3703     * targets would be redundant with other app functionality. Filtered components will not
 9 3704     * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
10 3705     */
11 3706    public static final String EXTRA_EXCLUDE_COMPONENTS
12 3707            = "android.intent.extra.EXCLUDE_COMPONENTS";

EXTRA_CHOOSER_TARGETS代表ACTION_CHOOSER要用的ChooserTarget,位置靠前

 1 3709    /**
 2 3710     * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
 3 3711     * describing additional high-priority deep-link targets for the chooser to present to the user.
 4 3712     *
 5 3713     * <p>Targets provided in this way will be presented inline with all other targets provided
 6 3714     * by services from other apps. They will be prioritized before other service targets, but
 7 3715     * after those targets provided by sources that the user has manually pinned to the front.</p>
 8 3716     *
 9 3717     * @see #ACTION_CHOOSER
10 3718     */
11 3719    public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";

EXTRA_REFINEMENT_INTENT_SENDER代表要啓動的Activity的IntentSender,在ACTION_CHOOSER裏作出選擇後發出。

 1 3721    /**
 2 3722     * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
 3 3723     * from the chooser activity presented by {@link #ACTION_CHOOSER}.
 4 3724     *
 5 3725     * <p>An app preparing an action for another app to complete may wish to allow the user to
 6 3726     * disambiguate between several options for completing the action based on the chosen target
 7 3727     * or otherwise refine the action before it is invoked.
 8 3728     * </p>
 9 3729     *
10 3730     * <p>When sent, this IntentSender may be filled in with the following extras:</p>
11 3731     * <ul>
12 3732     *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
13 3733     *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
14 3734     *     chosen target beyond the first</li>
15 3735     *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
16 3736     *     should fill in and send once the disambiguation is complete</li>
17 3737     * </ul>
18 3738     */
19 3739    public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
20 3740            = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";

EXTRA_RESULT_RECEIVER用來返回結果

 1 3742    /**
 2 3743     * A {@link ResultReceiver} used to return data back to the sender.
 3 3744     *
 4 3745     * <p>Used to complete an app-specific
 5 3746     * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
 6 3747     *
 7 3748     * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
 8 3749     * used to start a {@link #ACTION_CHOOSER} activity this extra will be
 9 3750     * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
10 3751     * when the user selects a target component from the chooser. It is up to the recipient
11 3752     * to send a result to this ResultReceiver to signal that disambiguation is complete
12 3753     * and that the chooser should invoke the user's choice.</p>
13 3754     *
14 3755     * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
15 3756     * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
16 3757     * to match and fill in the final Intent or ChooserTarget before starting it.
17 3758     * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
18 3759     * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
19 3760     * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
20 3761     *
21 3762     * <p>The result code passed to the ResultReceiver should be
22 3763     * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
23 3764     * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
24 3765     * the chooser should finish without starting a target.</p>
25 3766     */
26 3767    public static final String EXTRA_RESULT_RECEIVER
27 3768            = "android.intent.extra.RESULT_RECEIVER";

EXTRA_TITLE代表選擇對話框的標題

1 3770    /**
2 3771     * A CharSequence dialog title to provide to the user when used with a
3 3772     * {@link #ACTION_CHOOSER}.
4 3773     */
5 3774    public static final String EXTRA_TITLE = "android.intent.extra.TITLE";

EXTRA_INITIAL_INTENTS代表ACTION_CHOOSER初始化的Intents

1 3776    /**
2 3777     * A Parcelable[] of {@link Intent} or
3 3778     * {@link android.content.pm.LabeledIntent} objects as set with
4 3779     * {@link #putExtra(String, Parcelable[])} of additional activities to place
5 3780     * a the front of the list of choices, when shown to the user with a
6 3781     * {@link #ACTION_CHOOSER}.
7 3782     */
8 3783    public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";

EXTRA_EPHEMERAL_SUCCESS表示ephemeral安裝成功;EXTRA_EPHEMERAL_FAILURE表示ephemeral安裝失敗

 1 3785    /**
 2 3786     * A {@link IntentSender} to start after ephemeral installation success.
 3 3787     * @hide
 4 3788     */
 5 3789    public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
 6 3790
 7 3791    /**
 8 3792     * A {@link IntentSender} to start after ephemeral installation failure.
 9 3793     * @hide
10 3794     */
11 3795    public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";

EXTRA_REPLACEMENT_EXTRAS用來給不一樣的包添加額外的參數

 1 3797    /**
 2 3798     * A Bundle forming a mapping of potential target package names to different extras Bundles
 3 3799     * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
 4 3800     * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
 5 3801     * be currently installed on the device.
 6 3802     *
 7 3803     * <p>An application may choose to provide alternate extras for the case where a user
 8 3804     * selects an activity from a predetermined set of target packages. If the activity
 9 3805     * the user selects from the chooser belongs to a package with its package name as
10 3806     * a key in this bundle, the corresponding extras for that package will be merged with
11 3807     * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
12 3808     * extra has the same key as an extra already present in the intent it will overwrite
13 3809     * the extra from the intent.</p>
14 3810     *
15 3811     * <p><em>Examples:</em>
16 3812     * <ul>
17 3813     *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
18 3814     *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
19 3815     *     parameters for that target.</li>
20 3816     *     <li>An application may offer additional metadata for known targets of a given intent
21 3817     *     to pass along information only relevant to that target such as account or content
22 3818     *     identifiers already known to that application.</li>
23 3819     * </ul></p>
24 3820     */
25 3821    public static final String EXTRA_REPLACEMENT_EXTRAS =
26 3822            "android.intent.extra.REPLACEMENT_EXTRAS";

EXTRA_CHOSEN_COMPONENT_INTENT_SENDER用來在選中的Activity中發送回調;EXTRA_CHOSEN_COMPONENT代表選中組件的名字

 1 3824    /**
 2 3825     * An {@link IntentSender} that will be notified if a user successfully chooses a target
 3 3826     * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
 4 3827     * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
 5 3828     * {@link ComponentName} of the chosen component.
 6 3829     *
 7 3830     * <p>In some situations this callback may never come, for example if the user abandons
 8 3831     * the chooser, switches to another task or any number of other reasons. Apps should not
 9 3832     * be written assuming that this callback will always occur.</p>
10 3833     */
11 3834    public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
12 3835            "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
13 3836
14 3837    /**
15 3838     * The {@link ComponentName} chosen by the user to complete an action.
16 3839     *
17 3840     * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
18 3841     */
19 3842    public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
20 3843

EXTRA_KEY_EVENT用來包含觸發Intent的事件;EXTRA_KEY_CONFIRM爲真代表要用戶點擊肯定按鈕;EXTRA_USER_REQUESTED_SHUTDOWN代表是不是用戶觸發的shutdown

 1 3844    /**
 2 3845     * A {@link android.view.KeyEvent} object containing the event that
 3 3846     * triggered the creation of the Intent it is in.
 4 3847     */
 5 3848    public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
 6 3849
 7 3850    /**
 8 3851     * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
 9 3852     * before shutting down.
10 3853     *
11 3854     * {@hide}
12 3855     */
13 3856    public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
14 3857
15 3858    /**
16 3859     * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
17 3860     * requested by the user.
18 3861     *
19 3862     * {@hide}
20 3863     */
21 3864    public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
22 3865            "android.intent.extra.USER_REQUESTED_SHUTDOWN";

 EXTRA_DONT_KILL_APP指示是否在刪除包的時候殺掉app

1 3867    /**
2 3868     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3 3869     * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4 3870     * of restarting the application.
5 3871     */
6 3872    public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";

EXTRA_PHONE_NUMBER代表電話號碼

1 3874    /**
2 3875     * A String holding the phone number originally entered in
3 3876     * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4 3877     * number to call in a {@link android.content.Intent#ACTION_CALL}.
5 3878     */
6 3879    public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";

EXTRA_UID代表包的UID

1 3881    /**
2 3882     * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3 3883     * intents to supply the uid the package had been assigned.  Also an optional
4 3884     * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5 3885     * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
6 3886     * purpose.
7 3887     */
8 3888    public static final String EXTRA_UID = "android.intent.extra.UID";
9 3889

EXTRA_DATA_REMOVED指示是否要刪除包的數據

1 3896    /**
2 3897     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3 3898     * intents to indicate whether this represents a full uninstall (removing
4 3899     * both the code and its data) or a partial uninstall (leaving its data,
5 3900     * implying that this is an update).
6 3901     */
7 3902    public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";

EXTRA_REMOVED_FOR_ALL_USERS指示是否爲全部的用戶刪除包

1 3904    /**
2 3905     * @hide
3 3906     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4 3907     * intents to indicate that at this point the package has been removed for
5 3908     * all users on the device.
6 3909     */
7 3910    public static final String EXTRA_REMOVED_FOR_ALL_USERS
8 3911            = "android.intent.extra.REMOVED_FOR_ALL_USERS";

EXTRA_REPLACING代表包正在作替換

1 3913    /**
2 3914     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3 3915     * intents to indicate that this is a replacement of the package, so this
4 3916     * broadcast will immediately be followed by an add broadcast for a
5 3917     * different version of the same package.
6 3918     */
7 3919    public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";

EXTRA_ALARM_COUNT代表有多少個鬧鐘排隊等待喚醒

1 3921    /**
2 3922     * Used as an int extra field in {@link android.app.AlarmManager} intents
3 3923     * to tell the application being invoked how many pending alarms are being
4 3924     * delievered with the intent.  For one-shot alarms this will always be 1.
5 3925     * For recurring alarms, this might be greater than 1 if the device was
6 3926     * asleep or powered off at the time an earlier alarm would have been
7 3927     * delivered.
8 3928     */
9 3929    public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";

EXTRA_DOCK_STATE代表dock的狀態;EXTRA_DOCK_STATE_UNLOCKED代表沒有插入dock;EXTRA_DOCK_STATE_DESK代表dock是桌面模式;EXTRA_DOCK_STATE_CAR代表dock是car模式;EXTRA_DOCK_STATE_LE_DESK代表dock是low len桌面;EXTRA_DOCK_STATE_HE_DESK代表dock是high end桌面;METADATA_DOCK_HOME代表homekey由桌面dock接管

 1 3931    /**
 2 3932     * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
 3 3933     * intents to request the dock state.  Possible values are
 4 3934     * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
 5 3935     * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
 6 3936     * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
 7 3937     * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
 8 3938     * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
 9 3939     */
10 3940    public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
11 3941
12 3942    /**
13 3943     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
14 3944     * to represent that the phone is not in any dock.
15 3945     */
16 3946    public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
17 3947
18 3948    /**
19 3949     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
20 3950     * to represent that the phone is in a desk dock.
21 3951     */
22 3952    public static final int EXTRA_DOCK_STATE_DESK = 1;
23 3953
24 3954    /**
25 3955     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
26 3956     * to represent that the phone is in a car dock.
27 3957     */
28 3958    public static final int EXTRA_DOCK_STATE_CAR = 2;
29 3959
30 3960    /**
31 3961     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
32 3962     * to represent that the phone is in a analog (low end) dock.
33 3963     */
34 3964    public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
35 3965
36 3966    /**
37 3967     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
38 3968     * to represent that the phone is in a digital (high end) dock.
39 3969     */
40 3970    public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
41 3971
42 3972    /**
43 3973     * Boolean that can be supplied as meta-data with a dock activity, to
44 3974     * indicate that the dock should take over the home key when it is active.
45 3975     */
46 3976    public static final String METADATA_DOCK_HOME = "android.dock_home";

EXTRA_BUG_REPORT代表bug report的parcelable對象

1 3978    /**
2 3979     * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3 3980     * the bug report.
4 3981     */
5 3982    public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";

EXTRA_REMOTE_TOKEN爲remote intent用的token

1 3984    /**
2 3985     * Used in the extra field in the remote intent. It's astring token passed with the
3 3986     * remote intent.
4 3987     */
5 3988    public static final String EXTRA_REMOTE_INTENT_TOKEN =
6 3989            "android.intent.extra.remote_intent_token";

EXTRA_CHANGED_COMPONENT_NAME代表被改邊的component名字,已被廢棄;EXTRA_CHANGED_PACKAGE_LIST代表改變了的package list;EXTRA_CHANGED_UID_LIST代表改變了的uid list

 1 3991    /**
 2 3992     * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
 3 3993     * will contain only the first name in the list.
 4 3994     */
 5 3995    @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
 6 3996            "android.intent.extra.changed_component_name";
 7 3997
 8 3998    /**
 9 3999     * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
10 4000     * and contains a string array of all of the components that have changed.  If
11 4001     * the state of the overall package has changed, then it will contain an entry
12 4002     * with the package name itself.
13 4003     */
14 4004    public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
15 4005            "android.intent.extra.changed_component_name_list";
16 4006
17 4007    /**
18 4008     * This field is part of
19 4009     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
20 4010     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
21 4011     * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
22 4012     * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
23 4013     * and contains a string array of all of the components that have changed.
24 4014     */
25 4015    public static final String EXTRA_CHANGED_PACKAGE_LIST =
26 4016            "android.intent.extra.changed_package_list";
27 4017
28 4018    /**
29 4019     * This field is part of
30 4020     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
31 4021     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
32 4022     * and contains an integer array of uids of all of the components
33 4023     * that have changed.
34 4024     */
35 4025    public static final String EXTRA_CHANGED_UID_LIST =
36 4026            "android.intent.extra.changed_uid_list";

EXTRA_CLENT_LABEL在binding是代表誰綁定到了某個服務;EXTRA_CLENT_INTENT代表能夠被其啓動的PendingIntent

 1 4028    /**
 2 4029     * @hide
 3 4030     * Magic extra system code can use when binding, to give a label for
 4 4031     * who it is that has bound to a service.  This is an integer giving
 5 4032     * a framework string resource that can be displayed to the user.
 6 4033     */
 7 4034    public static final String EXTRA_CLIENT_LABEL =
 8 4035            "android.intent.extra.client_label";
 9 4036
10 4037    /**
11 4038     * @hide
12 4039     * Magic extra system code can use when binding, to give a PendingIntent object
13 4040     * that can be launched for the user to disable the system's use of this
14 4041     * service.
15 4042     */
16 4043    public static final String EXTRA_CLIENT_INTENT =
17 4044            "android.intent.extra.client_intent";

EXTRA_LOCAL_ONLY指示是不是隻使用本地的數據

 1 4046    /**
 2 4047     * Extra used to indicate that an intent should only return data that is on
 3 4048     * the local device. This is a boolean extra; the default is false. If true,
 4 4049     * an implementation should only allow the user to select data that is
 5 4050     * already on the device, not requiring it be downloaded from a remote
 6 4051     * service when opened.
 7 4052     *
 8 4053     * @see #ACTION_GET_CONTENT
 9 4054     * @see #ACTION_OPEN_DOCUMENT
10 4055     * @see #ACTION_OPEN_DOCUMENT_TREE
11 4056     * @see #ACTION_CREATE_DOCUMENT
12 4057     */
13 4058    public static final String EXTRA_LOCAL_ONLY =
14 4059            "android.intent.extra.LOCAL_ONLY";
15 4060

EXTRA_ALLOW_MULTIPLE容許選擇多個對象

 1 4061    /**
 2 4062     * Extra used to indicate that an intent can allow the user to select and
 3 4063     * return multiple items. This is a boolean extra; the default is false. If
 4 4064     * true, an implementation is allowed to present the user with a UI where
 5 4065     * they can pick multiple items that are all returned to the caller. When
 6 4066     * this happens, they should be returned as the {@link #getClipData()} part
 7 4067     * of the result Intent.
 8 4068     *
 9 4069     * @see #ACTION_GET_CONTENT
10 4070     * @see #ACTION_OPEN_DOCUMENT
11 4071     */
12 4072    public static final String EXTRA_ALLOW_MULTIPLE =
13 4073            "android.intent.extra.ALLOW_MULTIPLE";

EXTRA_USER_HANDLE代表用戶句柄

 1 4075    /**
 2 4076     * The integer userHandle carried with broadcast intents related to addition, removal and
 3 4077     * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
 4 4078     * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
 5 4079     *
 6 4080     * @hide
 7 4081     */
 8 4082    public static final String EXTRA_USER_HANDLE =
 9 4083            "android.intent.extra.user_handle";
10 4084

EXTRA_USER代表相應用戶

1 4085    /**
2 4086     * The UserHandle carried with broadcasts intents related to addition and removal of managed
3 4087     * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4 4088     */
5 4089    public static final String EXTRA_USER =
6 4090            "android.intent.extra.USER";

EXTRA_RESTRICTIONS_LIST,EXTRA_RESTRICTIONS_BUNDLE,EXTRA_RESTRICTIONS_INTENT代表相應限制權限的LIST,BUNDLE,INTENT

 1 4092    /**
 2 4093     * Extra used in the response from a BroadcastReceiver that handles
 3 4094     * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
 4 4095     * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
 5 4096     */
 6 4097    public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
 7 4098
 8 4099    /**
 9 4100     * Extra sent in the intent to the BroadcastReceiver that handles
10 4101     * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
11 4102     * the restrictions as key/value pairs.
12 4103     */
13 4104    public static final String EXTRA_RESTRICTIONS_BUNDLE =
14 4105            "android.intent.extra.restrictions_bundle";
15 4106
16 4107    /**
17 4108     * Extra used in the response from a BroadcastReceiver that handles
18 4109     * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
19 4110     */
20 4111    public static final String EXTRA_RESTRICTIONS_INTENT =
21 4112            "android.intent.extra.restrictions_intent";

EXTRA_MIME_TYPES代表MIME的類型

 1 4114    /**
 2 4115     * Extra used to communicate a set of acceptable MIME types. The type of the
 3 4116     * extra is {@code String[]}. Values may be a combination of concrete MIME
 4 4117     * types (such as "image/png") and/or partial MIME types (such as
 5 4118     * "audio/*").
 6 4119     *
 7 4120     * @see #ACTION_GET_CONTENT
 8 4121     * @see #ACTION_OPEN_DOCUMENT
 9 4122     */
10 4123    public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";

EXTRA_SHUTDOWN_USERSPACE_ONLY代表是否只是重啓用戶空間的軟件

 1 4125    /**
 2 4126     * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
 3 4127     * this shutdown is only for the user space of the system, not a complete shutdown.
 4 4128     * When this is true, hardware devices can use this information to determine that
 5 4129     * they shouldn't do a complete shutdown of their device since this is not a
 6 4130     * complete shutdown down to the kernel, but only user space restarting.
 7 4131     * The default if not supplied is false.
 8 4132     */
 9 4133    public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
10 4134            = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";

EXTRA_TIME_PREF_24_HOUR_FORMAT代表是否傾向24小時時間格式

1 4136    /**
2 4137     * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3 4138     * user has set their time format preferences to the 24 hour format.
4 4139     *
5 4140     * @hide for internal use only.
6 4141     */
7 4142    public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
8 4143            "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";

EXTRA_REASONG爲reboot reason

1 4145    /** {@hide} */
2 4146    public static final String EXTRA_REASON = "android.intent.extra.REASON";

EXTRA_SIM_ACTIVATION_RESPONSE代表sim激活的回覆

1 4151    /**
2 4152     * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3 4153     * activation request.
4 4154     * TODO: Add information about the structure and response data used with the pending intent.
5 4155     * @hide
6 4156     */
7 4157    public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
8 4158            "android.intent.extra.SIM_ACTIVATION_RESPONSE";
9 4159

EXTRA_INDEX取決於具體情景,代表不一樣的index

1 4160    /**
2 4161     * Optional index with semantics depending on the intent action.
3 4162     *
4 4163     * <p>The value must be an integer greater or equal to 0.
5 4164     */
6 4165    public static final String EXTRA_INDEX = "android.intent.extra.INDEX";

EXTRA_QUIET_MODE代表是否進入安靜模式

1 4160    /**
2 4161     * Optional index with semantics depending on the intent action.
3 4162     *
4 4163     * <p>The value must be an integer greater or equal to 0.
5 4164     */
6 4165    public static final String EXTRA_INDEX = "android.intent.extra.INDEX";

EXTRA_MEDIA_RESOURCE_TYPE代表過的的媒體類型;EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC代表媒體類型爲視頻;EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC代表媒體類型爲音頻

 1 4186    /**
 2 4187     * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
 3 4188     * to represent that a video codec is allowed to use.
 4 4189     *
 5 4190     * @hide
 6 4191     */
 7 4192    public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
 8 4193
 9 4194    /**
10 4195     * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
11 4196     * to represent that a audio codec is allowed to use.
12 4197     *
13 4198     * @hide
14 4199     */
15 4200    public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;

 

下面是Intent裏的flags

先是定義一個註解類GrantUriMode

 1 4202    // ---------------------------------------------------------------------
 2 4203    // ---------------------------------------------------------------------
 3 4204    // Intent flags (see mFlags variable).
 4 4205
 5 4206    /** @hide */
 6 4207    @IntDef(flag = true, value = {
 7 4208            FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
 8 4209            FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
 9 4210    @Retention(RetentionPolicy.SOURCE)
10 4211    public @interface GrantUriMode {}

而後是AccessUriMode註解類

1 4213    /** @hide */
2 4214    @IntDef(flag = true, value = {
3 4215            FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4 4216    @Retention(RetentionPolicy.SOURCE)
5 4217    public @interface AccessUriMode {}
6 4218

靜態函數isAccessUriMode代表是不是能夠訪問Uri模式

 1 4219    /**
 2 4220     * Test if given mode flags specify an access mode, which must be at least
 3 4221     * read and/or write.
 4 4222     *
 5 4223     * @hide
 6 4224     */
 7 4225    public static boolean isAccessUriMode(int modeFlags) {
 8 4226        return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
 9 4227                | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
10 4228    }

 FLAG_GRANT_READ_URI_PERMISSION和FLAG_GRANT_WRITE_URI_PERMISSION代表授予Intent接收者讀寫權限

 1 4230    /**
 2 4231     * If set, the recipient of this Intent will be granted permission to
 3 4232     * perform read operations on the URI in the Intent's data and any URIs
 4 4233     * specified in its ClipData.  When applying to an Intent's ClipData,
 5 4234     * all URIs as well as recursive traversals through data or other ClipData
 6 4235     * in Intent items will be granted; only the grant flags of the top-level
 7 4236     * Intent are used.
 8 4237     */
 9 4238    public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
10 4239    /**
11 4240     * If set, the recipient of this Intent will be granted permission to
12 4241     * perform write operations on the URI in the Intent's data and any URIs
13 4242     * specified in its ClipData.  When applying to an Intent's ClipData,
14 4243     * all URIs as well as recursive traversals through data or other ClipData
15 4244     * in Intent items will be granted; only the grant flags of the top-level
16 4245     * Intent are used.
17 4246     */
18 4247    public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;

FLAG_FROM_BACKGROUND代表Intent是從後臺程序發出來的

1 4248    /**
2 4249     * Can be set by the caller to indicate that this Intent is coming from
3 4250     * a background operation, not from direct user interaction.
4 4251     */
5 4252    public static final int FLAG_FROM_BACKGROUND = 0x00000004;

FLAG_DEBUG_LOG_RESOLUTION代表打印解析intent的log

1 4253    /**
2 4254     * A flag you can enable for debugging: when set, log messages will be
3 4255     * printed during the resolution of this intent to show you what has
4 4256     * been found to create the final resolved list.
5 4257     */
6 4258    public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;

FLAGS_EXCLUDE_STOPPED_PACKAGES代表排除中止運行的包;FLAG_INCLUDE_STOPPED_PACKAGES包含了中止運行的包,即便exclued的設置了

 1 4259    /**
 2 4260     * If set, this intent will not match any components in packages that
 3 4261     * are currently stopped.  If this is not set, then the default behavior
 4 4262     * is to include such applications in the result.
 5 4263     */
 6 4264    public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
 7 4265    /**
 8 4266     * If set, this intent will always match any components in packages that
 9 4267     * are currently stopped.  This is the default behavior when
10 4268     * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
11 4269     * flags are set, this one wins (it allows overriding of exclude for
12 4270     * places where the framework may automatically set the exclude flag).
13 4271     */
14 4272    public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;

FLAG_GRANT_PERSISTABLE_URI_PERMISSION代表權限受權會永久保留

 1 4274    /**
 2 4275     * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
 3 4276     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
 4 4277     * persisted across device reboots until explicitly revoked with
 5 4278     * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
 6 4279     * grant for possible persisting; the receiving application must call
 7 4280     * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
 8 4281     * actually persist.
 9 4282     *
10 4283     * @see ContentResolver#takePersistableUriPermission(Uri, int)
11 4284     * @see ContentResolver#releasePersistableUriPermission(Uri, int)
12 4285     * @see ContentResolver#getPersistedUriPermissions()
13 4286     * @see ContentResolver#getOutgoingPersistedUriPermissions()
14 4287     */
15 4288    public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;

FLAG_GRANT_PREFIX_URI_PERMISSION代表grant前綴匹配

 1 4290    /**
 2 4291     * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
 3 4292     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
 4 4293     * applies to any URI that is a prefix match against the original granted
 5 4294     * URI. (Without this flag, the URI must match exactly for access to be
 6 4295     * granted.) Another URI is considered a prefix match only when scheme,
 7 4296     * authority, and all path segments defined by the prefix are an exact
 8 4297     * match.
 9 4298     */
10 4299    public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;

FLAG_DEBUG_TRIAGED_MISSING代表已經系統組件驗證過包裏的組件了

 1 4301    /**
 2 4302     * Internal flag used to indicate that a system component has done their
 3 4303     * homework and verified that they correctly handle packages and components
 4 4304     * that come and go over time. In particular:
 5 4305     * <ul>
 6 4306     * <li>Apps installed on external storage, which will appear to be
 7 4307     * uninstalled while the the device is ejected.
 8 4308     * <li>Apps with encryption unaware components, which will appear to not
 9 4309     * exist while the device is locked.
10 4310     * </ul>
11 4311     *
12 4312     * @hide
13 4313     */
14 4314    public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
15 4315

FLAG_IGNORE_EPHEMERAL忽略ephemeral app

1 4316    /**
2 4317     * Internal flag used to indicate ephemeral applications should not be
3 4318     * considered when resolving the intent.
4 4319     *
5 4320     * @hide
6 4321     */
7 4322    public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
8 4323

FLAG_ACTIVITY_NO_HISTORY代表啓動的activity不會出如今歷史棧裏

 1 4324    /**
 2 4325     * If set, the new activity is not kept in the history stack.  As soon as
 3 4326     * the user navigates away from it, the activity is finished.  This may also
 4 4327     * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
 5 4328     * noHistory} attribute.
 6 4329     *
 7 4330     * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
 8 4331     * is never invoked when the current activity starts a new activity which
 9 4332     * sets a result and finishes.
10 4333     */
11 4334    public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;

FLAG_ACTIVITY_SINGLE_TOP代表activity只能在棧頂有一個實例

1 4335    /**
2 4336     * If set, the activity will not be launched if it is already running
3 4337     * at the top of the history stack.
4 4338     */
5 4339    public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;

FLAG_ACTIVITY_NEW_TASK代表activity新起一個task,在任務管理器裏新增一個。這個flag不能用於要求返回結果的activity

 1 4340    /**
 2 4341     * If set, this activity will become the start of a new task on this
 3 4342     * history stack.  A task (from the activity that started it to the
 4 4343     * next task activity) defines an atomic group of activities that the
 5 4344     * user can move to.  Tasks can be moved to the foreground and background;
 6 4345     * all of the activities inside of a particular task always remain in
 7 4346     * the same order.  See
 8 4347     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
 9 4348     * Stack</a> for more information about tasks.
10 4349     *
11 4350     * <p>This flag is generally used by activities that want
12 4351     * to present a "launcher" style behavior: they give the user a list of
13 4352     * separate things that can be done, which otherwise run completely
14 4353     * independently of the activity launching them.
15 4354     *
16 4355     * <p>When using this flag, if a task is already running for the activity
17 4356     * you are now starting, then a new activity will not be started; instead,
18 4357     * the current task will simply be brought to the front of the screen with
19 4358     * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
20 4359     * to disable this behavior.
21 4360     *
22 4361     * <p>This flag can not be used when the caller is requesting a result from
23 4362     * the activity being launched.
24 4363     */
25 4364    public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;

FLAG_ACTIVITY_MULTIPLE_TASK容許即便在一個activity已經存在於一個task的狀況下新開一個task

 1 4365    /**
 2 4366     * This flag is used to create a new task and launch an activity into it.
 3 4367     * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
 4 4368     * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
 5 4369     * search through existing tasks for ones matching this Intent. Only if no such
 6 4370     * task is found would a new task be created. When paired with
 7 4371     * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
 8 4372     * the search for a matching task and unconditionally start a new task.
 9 4373     *
10 4374     * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
11 4375     * flag unless you are implementing your own
12 4376     * top-level application launcher.</strong>  Used in conjunction with
13 4377     * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
14 4378     * behavior of bringing an existing task to the foreground.  When set,
15 4379     * a new task is <em>always</em> started to host the Activity for the
16 4380     * Intent, regardless of whether there is already an existing task running
17 4381     * the same thing.
18 4382     *
19 4383     * <p><strong>Because the default system does not include graphical task management,
20 4384     * you should not use this flag unless you provide some way for a user to
21 4385     * return back to the tasks you have launched.</strong>
22 4386     *
23 4387     * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
24 4388     * creating new document tasks.
25 4389     *
26 4390     * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
27 4391     * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
28 4392     *
29 4393     * <p>See
30 4394     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
31 4395     * Stack</a> for more information about tasks.
32 4396     *
33 4397     * @see #FLAG_ACTIVITY_NEW_DOCUMENT
34 4398     * @see #FLAG_ACTIVITY_NEW_TASK
35 4399     */
36 4400    public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;

FLAG_ACTIVITY_CLEAR_TOP清除目標activity之上的activity

 1 4401    /**
 2 4402     * If set, and the activity being launched is already running in the
 3 4403     * current task, then instead of launching a new instance of that activity,
 4 4404     * all of the other activities on top of it will be closed and this Intent
 5 4405     * will be delivered to the (now on top) old activity as a new Intent.
 6 4406     *
 7 4407     * <p>For example, consider a task consisting of the activities: A, B, C, D.
 8 4408     * If D calls startActivity() with an Intent that resolves to the component
 9 4409     * of activity B, then C and D will be finished and B receive the given
10 4410     * Intent, resulting in the stack now being: A, B.
11 4411     *
12 4412     * <p>The currently running instance of activity B in the above example will
13 4413     * either receive the new intent you are starting here in its
14 4414     * onNewIntent() method, or be itself finished and restarted with the
15 4415     * new intent.  If it has declared its launch mode to be "multiple" (the
16 4416     * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
17 4417     * the same intent, then it will be finished and re-created; for all other
18 4418     * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
19 4419     * Intent will be delivered to the current instance's onNewIntent().
20 4420     *
21 4421     * <p>This launch mode can also be used to good effect in conjunction with
22 4422     * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
23 4423     * of a task, it will bring any currently running instance of that task
24 4424     * to the foreground, and then clear it to its root state.  This is
25 4425     * especially useful, for example, when launching an activity from the
26 4426     * notification manager.
27 4427     *
28 4428     * <p>See
29 4429     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
30 4430     * Stack</a> for more information about tasks.
31 4431     */
32 4432    public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;

FLAG_ACTIVITY_FORWARD_RESULT代表新啓動的activity傳送的result將會給原來等待結果的,而不是如今的啓動者

1 4433    /**
2 4434     * If set and this intent is being used to launch a new activity from an
3 4435     * existing one, then the reply target of the existing activity will be
4 4436     * transfered to the new activity.  This way the new activity can call
5 4437     * {@link android.app.Activity#setResult} and have that result sent back to
6 4438     * the reply target of the original activity.
7 4439     */
8 4440    public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;

FLAG_ACTIVITY_PREVIOUS_IS_TOP代表前一個activity是top

1 4441    /**
2 4442     * If set and this intent is being used to launch a new activity from an
3 4443     * existing one, the current activity will not be counted as the top
4 4444     * activity for deciding whether the new intent should be delivered to
5 4445     * the top instead of starting a new one.  The previous activity will
6 4446     * be used as the top, with the assumption being that the current activity
7 4447     * will finish itself immediately.
8 4448     */
9 4449    public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;

FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS代表新的activity不會出如今最近的activity列表裏

1 4450    /**
2 4451     * If set, the new activity is not kept in the list of recently launched
3 4452     * activities.
4 4453     */
5 4454    public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;

FLAG_ACTIVITY_BROUGHT_TO_FRONT是系統爲單任務而設置

1 4455    /**
2 4456     * This flag is not normally set by application code, but set for you by
3 4457     * the system as described in the
4 4458     * {@link android.R.styleable#AndroidManifestActivity_launchMode
5 4459     * launchMode} documentation for the singleTask mode.
6 4460     */
7 4461    public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;

FLAG_ACTIVITY_RESET_TASK_IF_NEEDED代表activity被啓動爲一個新任務或者成爲某個task的top。致使相應的task被從新設置

1 4462    /**
2 4463     * If set, and this activity is either being started in a new task or
3 4464     * bringing to the top an existing task, then it will be launched as
4 4465     * the front door of the task.  This will result in the application of
5 4466     * any affinities needed to have that task in the proper state (either
6 4467     * moving activities to or from it), or simply resetting that task to
7 4468     * its initial state if needed.
8 4469     */
9 4470    public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;

FLAG_LAUNCHED_FROM_HISTORY代表從歷史中啓動,由系統設定

1 4471    /**
2 4472     * This flag is not normally set by application code, but set for you by
3 4473     * the system if this activity is being launched from history
4 4474     * (longpress home key).
5 4475     */
6 4476    public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;

FLAG_ACTIVITY_CLEAR_WHEN_TASK_CLEAR已經被廢棄,用FLAG_ACTIVITY_NEW_DOCUMENT取代

1 4477    /**
2 4478     * @deprecated As of API 21 this performs identically to
3 4479     * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
4 4480     */
5 4481    public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;

FLAG_ACTIVITY_NEW_DOCUMENT的值和FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET同樣,代表同一個activity的不一樣實例包含不一樣文檔能夠出如今最近任務列表裏

 1 4482    /**
 2 4483     * This flag is used to open a document into a new task rooted at the activity launched
 3 4484     * by this Intent. Through the use of this flag, or its equivalent attribute,
 4 4485     * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
 5 4486     * containing different documents will appear in the recent tasks list.
 6 4487     *
 7 4488     * <p>The use of the activity attribute form of this,
 8 4489     * {@link android.R.attr#documentLaunchMode}, is
 9 4490     * preferred over the Intent flag described here. The attribute form allows the
10 4491     * Activity to specify multiple document behavior for all launchers of the Activity
11 4492     * whereas using this flag requires each Intent that launches the Activity to specify it.
12 4493     *
13 4494     * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
14 4495     * it is kept after the activity is finished is different than the use of
15 4496     * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
16 4497     * this flag is being used to create a new recents entry, then by default that entry
17 4498     * will be removed once the activity is finished.  You can modify this behavior with
18 4499     * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
19 4500     *
20 4501     * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
21 4502     * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
22 4503     * equivalent of the Activity manifest specifying {@link
23 4504     * android.R.attr#documentLaunchMode}="intoExisting". When used with
24 4505     * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
25 4506     * {@link android.R.attr#documentLaunchMode}="always".
26 4507     *
27 4508     * Refer to {@link android.R.attr#documentLaunchMode} for more information.
28 4509     *
29 4510     * @see android.R.attr#documentLaunchMode
30 4511     * @see #FLAG_ACTIVITY_MULTIPLE_TASK
31 4512     */
32 4513    public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;

 FLAG_ACTIVITY_NO_USER_ACTION代表onUserLeaveHint不會被調用

 1 4514    /**
 2 4515     * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
 3 4516     * callback from occurring on the current frontmost activity before it is
 4 4517     * paused as the newly-started activity is brought to the front.
 5 4518     *
 6 4519     * <p>Typically, an activity can rely on that callback to indicate that an
 7 4520     * explicit user action has caused their activity to be moved out of the
 8 4521     * foreground. The callback marks an appropriate point in the activity's
 9 4522     * lifecycle for it to dismiss any notifications that it intends to display
10 4523     * "until the user has seen them," such as a blinking LED.
11 4524     *
12 4525     * <p>If an activity is ever started via any non-user-driven events such as
13 4526     * phone-call receipt or an alarm handler, this flag should be passed to {@link
14 4527     * Context#startActivity Context.startActivity}, ensuring that the pausing
15 4528     * activity does not think the user has acknowledged its notification.
16 4529     */
17 4530    public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;

FLAG_ACTIVITY_REORDER_TO_FRONT代表activity被啓動後要去棧頂

 1 4531    /**
 2 4532     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
 3 4533     * this flag will cause the launched activity to be brought to the front of its
 4 4534     * task's history stack if it is already running.
 5 4535     *
 6 4536     * <p>For example, consider a task consisting of four activities: A, B, C, D.
 7 4537     * If D calls startActivity() with an Intent that resolves to the component
 8 4538     * of activity B, then B will be brought to the front of the history stack,
 9 4539     * with this resulting order:  A, C, D, B.
10 4540     *
11 4541     * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
12 4542     * specified.
13 4543     */
14 4544    public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;

FLAG_ACTIVITY_NO_ANIMATION代表不顯示過場動畫

 1 4545    /**
 2 4546     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
 3 4547     * this flag will prevent the system from applying an activity transition
 4 4548     * animation to go to the next activity state.  This doesn't mean an
 5 4549     * animation will never run -- if another activity change happens that doesn't
 6 4550     * specify this flag before the activity started here is displayed, then
 7 4551     * that transition will be used.  This flag can be put to good use
 8 4552     * when you are going to do a series of activity operations but the
 9 4553     * animation seen by the user shouldn't be driven by the first activity
10 4554     * change but rather a later one.
11 4555     */
12 4556    public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;

FLAG_ACTIVITY_CLEAR_TASK代表舊的關聯task被清除

1 4557    /**
2 4558     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3 4559     * this flag will cause any existing task that would be associated with the
4 4560     * activity to be cleared before the activity is started.  That is, the activity
5 4561     * becomes the new root of an otherwise empty task, and any old activities
6 4562     * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
7 4563     */
8 4564    public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;

FLAG_ACTIVITY_TASK_ON_HOME代表退出這個task後返回到home界面

1 4565    /**
2 4566     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3 4567     * this flag will cause a newly launching task to be placed on top of the current
4 4568     * home activity task (if there is one).  That is, pressing back from the task
5 4569     * will always return the user to home even if that was not the last activity they
6 4570     * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
7 4571     */
8 4572    public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;

FLAG_ACTIVITY_RETAIN_IN_RECENTS代表activity保持在recent列表裏

 1 4573    /**
 2 4574     * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
 3 4575     * have its entry in recent tasks removed when the user closes it (with back
 4 4576     * or however else it may finish()). If you would like to instead allow the
 5 4577     * document to be kept in recents so that it can be re-launched, you can use
 6 4578     * this flag. When set and the task's activity is finished, the recents
 7 4579     * entry will remain in the interface for the user to re-launch it, like a
 8 4580     * recents entry for a top-level application.
 9 4581     * <p>
10 4582     * The receiving activity can override this request with
11 4583     * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
12 4584     * {@link android.app.Activity#finishAndRemoveTask()
13 4585     * Activity.finishAndRemoveTask()}.
14 4586     */
15 4587    public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;

FLAG_ACTIVITY_LAUNCH_ADJACENT用在多屏模式,代表activity在一個新的屏幕啓動

1 4589    /**
2 4590     * This flag is only used in split-screen multi-window mode. The new activity will be displayed
3 4591     * adjacent to the one launching it. This can only be used in conjunction with
4 4592     * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5 4593     * required if you want a new instance of an existing activity to be created.
6 4594     */
7 4595    public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
8 4596

FLAG_RECEIVER_REGISTER_ONLY代表只有註冊的Broadcast Receiver組件會響應

1 4597    /**
2 4598     * If set, when sending a broadcast only registered receivers will be
3 4599     * called -- no BroadcastReceiver components will be launched.
4 4600     */
5 4601    public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;

FLAG_RECEIVER_REPLACE_PENDING代表當前Intent替換Pending的Intent

 1 4602    /**
 2 4603     * If set, when sending a broadcast the new broadcast will replace
 3 4604     * any existing pending broadcast that matches it.  Matching is defined
 4 4605     * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
 5 4606     * true for the intents of the two broadcasts.  When a match is found,
 6 4607     * the new broadcast (and receivers associated with it) will replace the
 7 4608     * existing one in the pending broadcast list, remaining at the same
 8 4609     * position in the list.
 9 4610     *
10 4611     * <p>This flag is most typically used with sticky broadcasts, which
11 4612     * only care about delivering the most recent values of the broadcast
12 4613     * to their receivers.
13 4614     */
14 4615    public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;

FLAG_RECEIVER_FOREGROUND代表接受者到前臺運行

1 4616    /**
2 4617     * If set, when sending a broadcast the recipient is allowed to run at
3 4618     * foreground priority, with a shorter timeout interval.  During normal
4 4619     * broadcasts the receivers are not automatically hoisted out of the
5 4620     * background priority class.
6 4621     */
7 4622    public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;

FLAG_RECEIVER_NO_ABORT不容許放棄這個Intent

1 4623    /**
2 4624     * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
3 4625     * They can still propagate results through to later receivers, but they can not prevent
4 4626     * later receivers from seeing the broadcast.
5 4627     */
6 4628    public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;

FLAG_REVEIVER_REGISTERED_ONLY_BEFORE_BOOT代表只有boot以前註冊的組件會響應

 1 4629    /**
 2 4630     * If set, when sending a broadcast <i>before boot has completed</i> only
 3 4631     * registered receivers will be called -- no BroadcastReceiver components
 4 4632     * will be launched.  Sticky intent state will be recorded properly even
 5 4633     * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
 6 4634     * is specified in the broadcast intent, this flag is unnecessary.
 7 4635     *
 8 4636     * <p>This flag is only for use by system sevices as a convenience to
 9 4637     * avoid having to implement a more complex mechanism around detection
10 4638     * of boot completion.
11 4639     *
12 4640     * @hide
13 4641     */
14 4642    public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;

FLAG_RECEIVER_BOOG_UPGRADE代表在系統ready前能夠發Broadcast,爲boot upgrade而用

1 4643    /**
2 4644     * Set when this broadcast is for a boot upgrade, a special mode that
3 4645     * allows the broadcast to be sent before the system is ready and launches
4 4646     * the app process with no providers running in it.
5 4647     * @hide
6 4648     */
7 4649    public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;

FLAG_RECEIVER_INCLUDE_BACKGROUND代表只會找後臺的程序

1 4650    /**
2 4651     * If set, the broadcast will always go to manifest receivers in background (cached
3 4652     * or not running) apps, regardless of whether that would be done by default.  By
4 4653     * default they will only receive broadcasts if the broadcast has specified an
5 4654     * explicit component or package name.
6 4655     * @hide
7 4656     */
8 4657    public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;

FLAG_RECEIVER_EXCLUDE_BACKGROUND代表不包含後臺的程序

1 4658    /**
2 4659     * If set, the broadcast will never go to manifest receivers in background (cached
3 4660     * or not running) apps, regardless of whether that would be done by default.  By
4 4661     * default they will receive broadcasts if the broadcast has specified an
5 4662     * explicit component or package name.
6 4663     * @hide
7 4664     */
8 4665    public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;

IMMUTABLE_FLAGS是FLAG_GRANT_READ_URI_PERMISSION,FLAG_GRANT_WRIT_URI_PERMISSION,FLAG_GRANT_PERSISTABLE_URI_PERMISSION,FLAG_GRANT_PREFIX_URI_PERMISSION的組合

1 4667    /**
2 4668     * @hide Flags that can't be changed with PendingIntent.
3 4669     */
4 4670    public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5 4671            | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6 4672            | FLAG_GRANT_PREFIX_URI_PERMISSION

 URI_INTENT_SCHEME flag代表intetn: 組合

 1 4674    // ---------------------------------------------------------------------
 2 4675    // ---------------------------------------------------------------------
 3 4676    // toUri() and parseUri() options.
 4 4677
 5 4678    /**
 6 4679     * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
 7 4680     * always has the "intent:" scheme.  This syntax can be used when you want
 8 4681     * to later disambiguate between URIs that are intended to describe an
 9 4682     * Intent vs. all others that should be treated as raw URIs.  When used
10 4683     * with {@link #parseUri}, any other scheme will result in a generic
11 4684     * VIEW action for that raw URI.
12 4685     */
13 4686    public static final int URI_INTENT_SCHEME = 1<<0;

URI_ANDROID_APP_SCHEME代表app的scheme,爲了某個包名而作的簡化。Intent的內容能夠包含在這個URI裏

 1 4688    /**
 2 4689     * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
 3 4690     * always has the "android-app:" scheme.  This is a variation of
 4 4691     * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
 5 4692     * http/https URI being delivered to a specific package name.  The format
 6 4693     * is:
 7 4694     *
 8 4695     * <pre class="prettyprint">
 9 4696     * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
10 4697     *
11 4698     * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
12 4699     * you must also include a scheme; including a path also requires both a host and a scheme.
13 4700     * The final #Intent; fragment can be used without a scheme, host, or path.
14 4701     * Note that this can not be
15 4702     * used with intents that have a {@link #setSelector}, since the base intent
16 4703     * will always have an explicit package name.</p>
17 4704     *
18 4705     * <p>Some examples of how this scheme maps to Intent objects:</p>
19 4706     * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
20 4707     *     <colgroup align="left" />
21 4708     *     <colgroup align="left" />
22 4709     *     <thead>
23 4710     *     <tr><th>URI</th> <th>Intent</th></tr>
24 4711     *     </thead>
25 4712     *
26 4713     *     <tbody>
27 4714     *     <tr><td><code>android-app://com.example.app</code></td>
28 4715     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
29 4716     *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
30 4717     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
31 4718     *         </table></td>
32 4719     *     </tr>
33 4720     *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
34 4721     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
35 4722     *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
36 4723     *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
37 4724     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
38 4725     *         </table></td>
39 4726     *     </tr>
40 4727     *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
41 4728     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
42 4729     *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
43 4730     *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
44 4731     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
45 4732     *         </table></td>
46 4733     *     </tr>
47 4734     *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
48 4735     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
49 4736     *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
50 4737     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
51 4738     *         </table></td>
52 4739     *     </tr>
53 4740     *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
54 4741     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
55 4742     *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
56 4743     *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
57 4744     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
58 4745     *         </table></td>
59 4746     *     </tr>
60 4747     *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
61 4748     *         <td><table border="" style="margin:0" >
62 4749     *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
63 4750     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
64 4751     *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
65 4752     *         </table></td>
66 4753     *     </tr>
67 4754     *     </tbody>
68 4755     * </table>
69 4756     */
70 4757    public static final int URI_ANDROID_APP_SCHEME = 1<<1;

URI_ALLOW_UNSAFE代表容許解析不安全的信息

 1 4759    /**
 2 4760     * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
 3 4761     * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
 4 4762     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
 5 4763     * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
 6 4764     * generated Intent can not cause unexpected data access to happen.
 7 4765     *
 8 4766     * <p>If you do not trust the source of the URI being parsed, you should still do further
 9 4767     * processing to protect yourself from it.  In particular, when using it to start an
10 4768     * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
11 4769     * that can handle it.</p>
12 4770     */
13 4771    public static final int URI_ALLOW_UNSAFE = 1<<2;

 下邊幾個私有變量是Intent抽下的動做、數據、type、類別、extra、flags、對應組件、Intent seclector、clipdata、user、packange信息等內容,共12個

 1 4775    private String mAction;
 2 4776    private Uri mData;
 3 4777    private String mType;
 4 4778    private String mPackage;
 5 4779    private ComponentName mComponent;
 6 4780    private int mFlags;
 7 4781    private ArraySet<String> mCategories;
 8 4782    private Bundle mExtras;
 9 4783    private Rect mSourceBounds;
10 4784    private Intent mSelector;
11 4785    private ClipData mClipData;
12 4786    private int mContentUserHint = UserHandle.USER_CURRENT;

下面看方法

構造函數與clone函數

 1 4788    // ---------------------------------------------------------------------
 2 4789
 3 4790    /**
 4 4791     * Create an empty intent.
 5 4792     */
 6 4793    public Intent() {
 7 4794    }
 8 4795
 9 4796    /**
10 4797     * Copy constructor.
11 4798     */
12 4799    public Intent(Intent o) {
13 4800        this.mAction = o.mAction;
14 4801        this.mData = o.mData;
15 4802        this.mType = o.mType;
16 4803        this.mPackage = o.mPackage;
17 4804        this.mComponent = o.mComponent;
18 4805        this.mFlags = o.mFlags;
19 4806        this.mContentUserHint = o.mContentUserHint;
20 4807        if (o.mCategories != null) {
21 4808            this.mCategories = new ArraySet<String>(o.mCategories);
22 4809        }
23 4810        if (o.mExtras != null) {
24 4811            this.mExtras = new Bundle(o.mExtras);
25 4812        }
26 4813        if (o.mSourceBounds != null) {
27 4814            this.mSourceBounds = new Rect(o.mSourceBounds);
28 4815        }
29 4816        if (o.mSelector != null) {
30 4817            this.mSelector = new Intent(o.mSelector);
31 4818        }
32 4819        if (o.mClipData != null) {
33 4820            this.mClipData = new ClipData(o.mClipData);
34 4821        }
35 4822    }
36 4823
37 4824    @Override
38 4825    public Object clone() {
39 4826        return new Intent(this);
40 4827    }
41 4828
42 4829    private Intent(Intent o, boolean all) {
43 4830        this.mAction = o.mAction;
44 4831        this.mData = o.mData;
45 4832        this.mType = o.mType;
46 4833        this.mPackage = o.mPackage;
47 4834        this.mComponent = o.mComponent;
48 4835        if (o.mCategories != null) {
49 4836            this.mCategories = new ArraySet<String>(o.mCategories);
50 4837        }
51 4838    }
52 4839
53 4840    /**
54 4841     * Make a clone of only the parts of the Intent that are relevant for
55 4842     * filter matching: the action, data, type, component, and categories.
56 4843     */
57 4844    public Intent cloneFilter() {
58 4845        return new Intent(this, false);
59 4846    }

下邊這幾個構造函數初始化Intent的部分變量

 1 4848    /**
 2 4849     * Create an intent with a given action.  All other fields (data, type,
 3 4850     * class) are null.  Note that the action <em>must</em> be in a
 4 4851     * namespace because Intents are used globally in the system -- for
 5 4852     * example the system VIEW action is android.intent.action.VIEW; an
 6 4853     * application's custom action would be something like
 7 4854     * com.google.app.myapp.CUSTOM_ACTION.
 8 4855     *
 9 4856     * @param action The Intent action, such as ACTION_VIEW.
10 4857     */
11 4858    public Intent(String action) {
12 4859        setAction(action);
13 4860    }
14 4861
15 4862    /**
16 4863     * Create an intent with a given action and for a given data url.  Note
17 4864     * that the action <em>must</em> be in a namespace because Intents are
18 4865     * used globally in the system -- for example the system VIEW action is
19 4866     * android.intent.action.VIEW; an application's custom action would be
20 4867     * something like com.google.app.myapp.CUSTOM_ACTION.
21 4868     *
22 4869     * <p><em>Note: scheme and host name matching in the Android framework is
23 4870     * case-sensitive, unlike the formal RFC.  As a result,
24 4871     * you should always ensure that you write your Uri with these elements
25 4872     * using lower case letters, and normalize any Uris you receive from
26 4873     * outside of Android to ensure the scheme and host is lower case.</em></p>
27 4874     *
28 4875     * @param action The Intent action, such as ACTION_VIEW.
29 4876     * @param uri The Intent data URI.
30 4877     */
31 4878    public Intent(String action, Uri uri) {
32 4879        setAction(action);
33 4880        mData = uri;
34 4881    }
35 4882
36 4883    /**
37 4884     * Create an intent for a specific component.  All other fields (action, data,
38 4885     * type, class) are null, though they can be modified later with explicit
39 4886     * calls.  This provides a convenient way to create an intent that is
40 4887     * intended to execute a hard-coded class name, rather than relying on the
41 4888     * system to find an appropriate class for you; see {@link #setComponent}
42 4889     * for more information on the repercussions of this.
43 4890     *
44 4891     * @param packageContext A Context of the application package implementing
45 4892     * this class.
46 4893     * @param cls The component class that is to be used for the intent.
47 4894     *
48 4895     * @see #setClass
49 4896     * @see #setComponent
50 4897     * @see #Intent(String, android.net.Uri , Context, Class)
51 4898     */
52 4899    public Intent(Context packageContext, Class<?> cls) {
53 4900        mComponent = new ComponentName(packageContext, cls);
54 4901    }
55 4902
56 4903    /**
57 4904     * Create an intent for a specific component with a specified action and data.
58 4905     * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
59 4906     * construct the Intent and then calling {@link #setClass} to set its
60 4907     * class.
61 4908     *
62 4909     * <p><em>Note: scheme and host name matching in the Android framework is
63 4910     * case-sensitive, unlike the formal RFC.  As a result,
64 4911     * you should always ensure that you write your Uri with these elements
65 4912     * using lower case letters, and normalize any Uris you receive from
66 4913     * outside of Android to ensure the scheme and host is lower case.</em></p>
67 4914     *
68 4915     * @param action The Intent action, such as ACTION_VIEW.
69 4916     * @param uri The Intent data URI.
70 4917     * @param packageContext A Context of the application package implementing
71 4918     * this class.
72 4919     * @param cls The component class that is to be used for the intent.
73 4920     *
74 4921     * @see #Intent(String, android.net.Uri)
75 4922     * @see #Intent(Context, Class)
76 4923     * @see #setClass
77 4924     * @see #setComponent
78 4925     */
79 4926    public Intent(String action, Uri uri,
80 4927            Context packageContext, Class<?> cls) {
81 4928        setAction(action);
82 4929        mData = uri;
83 4930        mComponent = new ComponentName(packageContext, cls);
84 4931    }

makeMainActivity製做一個action爲ACTION_MAIN,category爲CATEGORY_LAUNCHER的Intent,並指定組件名字

 1 4933    /**
 2 4934     * Create an intent to launch the main (root) activity of a task.  This
 3 4935     * is the Intent that is started when the application's is launched from
 4 4936     * Home.  For anything else that wants to launch an application in the
 5 4937     * same way, it is important that they use an Intent structured the same
 6 4938     * way, and can use this function to ensure this is the case.
 7 4939     *
 8 4940     * <p>The returned Intent has the given Activity component as its explicit
 9 4941     * component, {@link #ACTION_MAIN} as its action, and includes the
10 4942     * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
11 4943     * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
12 4944     * to do that through {@link #addFlags(int)} on the returned Intent.
13 4945     *
14 4946     * @param mainActivity The main activity component that this Intent will
15 4947     * launch.
16 4948     * @return Returns a newly created Intent that can be used to launch the
17 4949     * activity as a main application entry.
18 4950     *
19 4951     * @see #setClass
20 4952     * @see #setComponent
21 4953     */
22 4954    public static Intent makeMainActivity(ComponentName mainActivity) {
23 4955        Intent intent = new Intent(ACTION_MAIN);
24 4956        intent.setComponent(mainActivity);
25 4957        intent.addCategory(CATEGORY_LAUNCHER);
26 4958        return intent;
27 4959    }
28 4960

makeMainSelectorActivity沒有指定要啓動的組件名,而是經過設置一個SelectorIntetn指定其selectorAction和seclectorCategory

 1 4961    /**
 2 4962     * Make an Intent for the main activity of an application, without
 3 4963     * specifying a specific activity to run but giving a selector to find
 4 4964     * the activity.  This results in a final Intent that is structured
 5 4965     * the same as when the application is launched from
 6 4966     * Home.  For anything else that wants to launch an application in the
 7 4967     * same way, it is important that they use an Intent structured the same
 8 4968     * way, and can use this function to ensure this is the case.
 9 4969     *
10 4970     * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
11 4971     * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
12 4972     * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
13 4973     * to do that through {@link #addFlags(int)} on the returned Intent.
14 4974     *
15 4975     * @param selectorAction The action name of the Intent's selector.
16 4976     * @param selectorCategory The name of a category to add to the Intent's
17 4977     * selector.
18 4978     * @return Returns a newly created Intent that can be used to launch the
19 4979     * activity as a main application entry.
20 4980     *
21 4981     * @see #setSelector(Intent)
22 4982     */
23 4983    public static Intent makeMainSelectorActivity(String selectorAction,
24 4984            String selectorCategory) {
25 4985        Intent intent = new Intent(ACTION_MAIN);
26 4986        intent.addCategory(CATEGORY_LAUNCHER);
27 4987        Intent selector = new Intent();
28 4988        selector.setAction(selectorAction);
29 4989        selector.addCategory(selectorCategory);
30 4990        intent.setSelector(selector);
31 4991        return intent;
32 4992    }
33 4993

makeRestartActivityTask代表創建一個新的task,並移除舊的task

 1 4994    /**
 2 4995     * Make an Intent that can be used to re-launch an application's task
 3 4996     * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
 4 4997     * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
 5 4998     * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
 6 4999     *
 7 5000     * @param mainActivity The activity component that is the root of the
 8 5001     * task; this is the activity that has been published in the application's
 9 5002     * manifest as the main launcher icon.
10 5003     *
11 5004     * @return Returns a newly created Intent that can be used to relaunch the
12 5005     * activity's task in its root state.
13 5006     */
14 5007    public static Intent makeRestartActivityTask(ComponentName mainActivity) {
15 5008        Intent intent = makeMainActivity(mainActivity);
16 5009        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
17 5010                | Intent.FLAG_ACTIVITY_CLEAR_TASK);
18 5011        return intent;
19 5012    }
20 5013

getIntent調用parseUri,解析傳入的Uri

1 5014    /**
2 5015     * Call {@link #parseUri} with 0 flags.
3 5016     * @deprecated Use {@link #parseUri} instead.
4 5017     */
5 5018    @Deprecated
6 5019    public static Intent getIntent(String uri) throws URISyntaxException {
7 5020        return parseUri(uri, 0);
8 5021    }

 parseUri把傳入的Uri轉換爲一個Intent

  1 5023    /**
  2 5024     * Create an intent from a URI.  This URI may encode the action,
  3 5025     * category, and other intent fields, if it was returned by
  4 5026     * {@link #toUri}.  If the Intent was not generate by toUri(), its data
  5 5027     * will be the entire URI and its action will be ACTION_VIEW.
  6 5028     *
  7 5029     * <p>The URI given here must not be relative -- that is, it must include
  8 5030     * the scheme and full path.
  9 5031     *
 10 5032     * @param uri The URI to turn into an Intent.
 11 5033     * @param flags Additional processing flags.  Either 0,
 12 5034     * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
 13 5035     *
 14 5036     * @return Intent The newly created Intent object.
 15 5037     *
 16 5038     * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
 17 5039     * it bad (as parsed by the Uri class) or the Intent data within the
 18 5040     * URI is invalid.
 19 5041     *
 20 5042     * @see #toUri
 21 5043     */
 22 5044    public static Intent parseUri(String uri, int flags) throws URISyntaxException {
 23 5045        int i = 0;
 24 5046        try {
 25 5047            final boolean androidApp = uri.startsWith("android-app:");
 26 5048
 27 5049            // Validate intent scheme if requested.
 28 5050            if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
 29 5051                if (!uri.startsWith("intent:") && !androidApp) {
 30 5052                    Intent intent = new Intent(ACTION_VIEW);
 31 5053                    try {
 32 5054                        intent.setData(Uri.parse(uri));
 33 5055                    } catch (IllegalArgumentException e) {
 34 5056                        throw new URISyntaxException(uri, e.getMessage());
 35 5057                    }
 36 5058                    return intent;
 37 5059                }
 38 5060            }
 39 5061
 40 5062            i = uri.lastIndexOf("#");
 41 5063            // simple case
 42 5064            if (i == -1) {
 43 5065                if (!androidApp) {
 44 5066                    return new Intent(ACTION_VIEW, Uri.parse(uri));
 45 5067                }
 46 5068
 47 5069            // old format Intent URI
 48 5070            } else if (!uri.startsWith("#Intent;", i)) {
 49 5071                if (!androidApp) {
 50 5072                    return getIntentOld(uri, flags);
 51 5073                } else {
 52 5074                    i = -1;
 53 5075                }
 54 5076            }
 55 5077
 56 5078            // new format
 57 5079            Intent intent = new Intent(ACTION_VIEW);
 58 5080            Intent baseIntent = intent;
 59 5081            boolean explicitAction = false;
 60 5082            boolean inSelector = false;
 61 5083
 62 5084            // fetch data part, if present
 63 5085            String scheme = null;
 64 5086            String data;
 65 5087            if (i >= 0) {
 66 5088                data = uri.substring(0, i);
 67 5089                i += 8; // length of "#Intent;"
 68 5090            } else {
 69 5091                data = uri;
 70 5092            }
 71 5093
 72 5094            // loop over contents of Intent, all name=value;
 73 5095            while (i >= 0 && !uri.startsWith("end", i)) {
 74 5096                int eq = uri.indexOf('=', i);
 75 5097                if (eq < 0) eq = i-1;
 76 5098                int semi = uri.indexOf(';', i);
 77 5099                String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
 78 5100
 79 5101                // action
 80 5102                if (uri.startsWith("action=", i)) {
 81 5103                    intent.setAction(value);
 82 5104                    if (!inSelector) {
 83 5105                        explicitAction = true;
 84 5106                    }
 85 5107                }
 86 5108
 87 5109                // categories
 88 5110                else if (uri.startsWith("category=", i)) {
 89 5111                    intent.addCategory(value);
 90 5112                }
 91 5113
 92 5114                // type
 93 5115                else if (uri.startsWith("type=", i)) {
 94 5116                    intent.mType = value;
 95 5117                }
 96 5118
 97 5119                // launch flags
 98 5120                else if (uri.startsWith("launchFlags=", i)) {
 99 5121                    intent.mFlags = Integer.decode(value).intValue();
100 5122                    if ((flags& URI_ALLOW_UNSAFE) == 0) {
101 5123                        intent.mFlags &= ~IMMUTABLE_FLAGS;
102 5124                    }
103 5125                }
104 5126
105 5127                // package
106 5128                else if (uri.startsWith("package=", i)) {
107 5129                    intent.mPackage = value;
108 5130                }
109 5131
110 5132                // component
111 5133                else if (uri.startsWith("component=", i)) {
112 5134                    intent.mComponent = ComponentName.unflattenFromString(value);
113 5135                }
114 5136
115 5137                // scheme
116 5138                else if (uri.startsWith("scheme=", i)) {
117 5139                    if (inSelector) {
118 5140                        intent.mData = Uri.parse(value + ":");
119 5141                    } else {
120 5142                        scheme = value;
121 5143                    }
122 5144                }
123 5145
124 5146                // source bounds
125 5147                else if (uri.startsWith("sourceBounds=", i)) {
126 5148                    intent.mSourceBounds = Rect.unflattenFromString(value);
127 5149                }
128 5150
129 5151                // selector
130 5152                else if (semi == (i+3) && uri.startsWith("SEL", i)) {
131 5153                    intent = new Intent();
132 5154                    inSelector = true;
133 5155                }
134 5156
135 5157                // extra
136 5158                else {
137 5159                    String key = Uri.decode(uri.substring(i + 2, eq));
138 5160                    // create Bundle if it doesn't already exist
139 5161                    if (intent.mExtras == null) intent.mExtras = new Bundle();
140 5162                    Bundle b = intent.mExtras;
141 5163                    // add EXTRA
142 5164                    if      (uri.startsWith("S.", i)) b.putString(key, value);
143 5165                    else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
144 5166                    else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
145 5167                    else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
146 5168                    else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
147 5169                    else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
148 5170                    else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
149 5171                    else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
150 5172                    else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
151 5173                    else throw new URISyntaxException(uri, "unknown EXTRA type", i);
152 5174                }
153 5175
154 5176                // move to the next item
155 5177                i = semi + 1;
156 5178            }
157 5179
158 5180            if (inSelector) {
159 5181                // The Intent had a selector; fix it up.
160 5182                if (baseIntent.mPackage == null) {
161 5183                    baseIntent.setSelector(intent);
162 5184                }
163 5185                intent = baseIntent;
164 5186            }
165 5187
166 5188            if (data != null) {
167 5189                if (data.startsWith("intent:")) {
168 5190                    data = data.substring(7);
169 5191                    if (scheme != null) {
170 5192                        data = scheme + ':' + data;
171 5193                    }
172 5194                } else if (data.startsWith("android-app:")) {
173 5195                    if (data.charAt(12) == '/' && data.charAt(13) == '/') {
174 5196                        // Correctly formed android-app, first part is package name.
175 5197                        int end = data.indexOf('/', 14);
176 5198                        if (end < 0) {
177 5199                            // All we have is a package name.
178 5200                            intent.mPackage = data.substring(14);
179 5201                            if (!explicitAction) {
180 5202                                intent.setAction(ACTION_MAIN);
181 5203                            }
182 5204                            data = "";
183 5205                        } else {
184 5206                            // Target the Intent at the given package name always.
185 5207                            String authority = null;
186 5208                            intent.mPackage = data.substring(14, end);
187 5209                            int newEnd;
188 5210                            if ((end+1) < data.length()) {
189 5211                                if ((newEnd=data.indexOf('/', end+1)) >= 0) {
190 5212                                    // Found a scheme, remember it.
191 5213                                    scheme = data.substring(end+1, newEnd);
192 5214                                    end = newEnd;
193 5215                                    if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
194 5216                                        // Found a authority, remember it.
195 5217                                        authority = data.substring(end+1, newEnd);
196 5218                                        end = newEnd;
197 5219                                    }
198 5220                                } else {
199 5221                                    // All we have is a scheme.
200 5222                                    scheme = data.substring(end+1);
201 5223                                }
202 5224                            }
203 5225                            if (scheme == null) {
204 5226                                // If there was no scheme, then this just targets the package.
205 5227                                if (!explicitAction) {
206 5228                                    intent.setAction(ACTION_MAIN);
207 5229                                }
208 5230                                data = "";
209 5231                            } else if (authority == null) {
210 5232                                data = scheme + ":";
211 5233                            } else {
212 5234                                data = scheme + "://" + authority + data.substring(end);
213 5235                            }
214 5236                        }
215 5237                    } else {
216 5238                        data = "";
217 5239                    }
218 5240                }
219 5241
220 5242                if (data.length() > 0) {
221 5243                    try {
222 5244                        intent.mData = Uri.parse(data);
223 5245                    } catch (IllegalArgumentException e) {
224 5246                        throw new URISyntaxException(uri, e.getMessage());
225 5247                    }
226 5248                }
227 5249            }
228 5250
229 5251            return intent;
230 5252
231 5253        } catch (IndexOutOfBoundsException e) {
232 5254            throw new URISyntaxException(uri, "illegal Intent URI format", i);
233 5255        }
234 5256    }

getIntentOld解析舊的Uri格式

  1 5258    public static Intent getIntentOld(String uri) throws URISyntaxException {
  2 5259        return getIntentOld(uri, 0);
  3 5260    }
  4 5261
  5 5262    private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
  6 5263        Intent intent;
  7 5264
  8 5265        int i = uri.lastIndexOf('#');
  9 5266        if (i >= 0) {
 10 5267            String action = null;
 11 5268            final int intentFragmentStart = i;
 12 5269            boolean isIntentFragment = false;
 13 5270
 14 5271            i++;
 15 5272
 16 5273            if (uri.regionMatches(i, "action(", 0, 7)) {
 17 5274                isIntentFragment = true;
 18 5275                i += 7;
 19 5276                int j = uri.indexOf(')', i);
 20 5277                action = uri.substring(i, j);
 21 5278                i = j + 1;
 22 5279            }
 23 5280
 24 5281            intent = new Intent(action);
 25 5282
 26 5283            if (uri.regionMatches(i, "categories(", 0, 11)) {
 27 5284                isIntentFragment = true;
 28 5285                i += 11;
 29 5286                int j = uri.indexOf(')', i);
 30 5287                while (i < j) {
 31 5288                    int sep = uri.indexOf('!', i);
 32 5289                    if (sep < 0 || sep > j) sep = j;
 33 5290                    if (i < sep) {
 34 5291                        intent.addCategory(uri.substring(i, sep));
 35 5292                    }
 36 5293                    i = sep + 1;
 37 5294                }
 38 5295                i = j + 1;
 39 5296            }
 40 5297
 41 5298            if (uri.regionMatches(i, "type(", 0, 5)) {
 42 5299                isIntentFragment = true;
 43 5300                i += 5;
 44 5301                int j = uri.indexOf(')', i);
 45 5302                intent.mType = uri.substring(i, j);
 46 5303                i = j + 1;
 47 5304            }
 48 5305
 49 5306            if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
 50 5307                isIntentFragment = true;
 51 5308                i += 12;
 52 5309                int j = uri.indexOf(')', i);
 53 5310                intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
 54 5311                if ((flags& URI_ALLOW_UNSAFE) == 0) {
 55 5312                    intent.mFlags &= ~IMMUTABLE_FLAGS;
 56 5313                }
 57 5314                i = j + 1;
 58 5315            }
 59 5316
 60 5317            if (uri.regionMatches(i, "component(", 0, 10)) {
 61 5318                isIntentFragment = true;
 62 5319                i += 10;
 63 5320                int j = uri.indexOf(')', i);
 64 5321                int sep = uri.indexOf('!', i);
 65 5322                if (sep >= 0 && sep < j) {
 66 5323                    String pkg = uri.substring(i, sep);
 67 5324                    String cls = uri.substring(sep + 1, j);
 68 5325                    intent.mComponent = new ComponentName(pkg, cls);
 69 5326                }
 70 5327                i = j + 1;
 71 5328            }
 72 5329
 73 5330            if (uri.regionMatches(i, "extras(", 0, 7)) {
 74 5331                isIntentFragment = true;
 75 5332                i += 7;
 76 5333
 77 5334                final int closeParen = uri.indexOf(')', i);
 78 5335                if (closeParen == -1) throw new URISyntaxException(uri,
 79 5336                        "EXTRA missing trailing ')'", i);
 80 5337
 81 5338                while (i < closeParen) {
 82 5339                    // fetch the key value
 83 5340                    int j = uri.indexOf('=', i);
 84 5341                    if (j <= i + 1 || i >= closeParen) {
 85 5342                        throw new URISyntaxException(uri, "EXTRA missing '='", i);
 86 5343                    }
 87 5344                    char type = uri.charAt(i);
 88 5345                    i++;
 89 5346                    String key = uri.substring(i, j);
 90 5347                    i = j + 1;
 91 5348
 92 5349                    // get type-value
 93 5350                    j = uri.indexOf('!', i);
 94 5351                    if (j == -1 || j >= closeParen) j = closeParen;
 95 5352                    if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
 96 5353                    String value = uri.substring(i, j);
 97 5354                    i = j;
 98 5355
 99 5356                    // create Bundle if it doesn't already exist
100 5357                    if (intent.mExtras == null) intent.mExtras = new Bundle();
101 5358
102 5359                    // add item to bundle
103 5360                    try {
104 5361                        switch (type) {
105 5362                            case 'S':
106 5363                                intent.mExtras.putString(key, Uri.decode(value));
107 5364                                break;
108 5365                            case 'B':
109 5366                                intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
110 5367                                break;
111 5368                            case 'b':
112 5369                                intent.mExtras.putByte(key, Byte.parseByte(value));
113 5370                                break;
114 5371                            case 'c':
115 5372                                intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
116 5373                                break;
117 5374                            case 'd':
118 5375                                intent.mExtras.putDouble(key, Double.parseDouble(value));
119 5376                                break;
120 5377                            case 'f':
121 5378                                intent.mExtras.putFloat(key, Float.parseFloat(value));
122 5379                                break;
123 5380                            case 'i':
124 5381                                intent.mExtras.putInt(key, Integer.parseInt(value));
125 5382                                break;
126 5383                            case 'l':
127 5384                                intent.mExtras.putLong(key, Long.parseLong(value));
128 5385                                break;
129 5386                            case 's':
130 5387                                intent.mExtras.putShort(key, Short.parseShort(value));
131 5388                                break;
132 5389                            default:
133 5390                                throw new URISyntaxException(uri, "EXTRA has unknown type", i);
134 5391                        }
135 5392                    } catch (NumberFormatException e) {
136 5393                        throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
137 5394                    }
138 5395
139 5396                    char ch = uri.charAt(i);
140 5397                    if (ch == ')') break;
141 5398                    if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
142 5399                    i++;
143 5400                }
144 5401            }
145 5402
146 5403            if (isIntentFragment) {
147 5404                intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
148 5405            } else {
149 5406                intent.mData = Uri.parse(uri);
150 5407            }
151 5408
152 5409            if (intent.mAction == null) {
153 5410                // By default, if no action is specified, then use VIEW.
154 5411                intent.mAction = ACTION_VIEW;
155 5412            }
156 5413
157 5414        } else {
158 5415            intent = new Intent(ACTION_VIEW, Uri.parse(uri));
159 5416        }
160 5417
161 5418        return intent;
162 5419    }
163 5420

內部接口CommandOptionHanlder有一個函數handleOption

1 5421    /** @hide */
2 5422    public interface CommandOptionHandler {
3 5423        boolean handleOption(String opt, ShellCommand cmd);
4 5424    }
5 5425

parseCommnadArgs解析shellcommand

  1 5426    /** @hide */
  2 5427    public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
  3 5428            throws URISyntaxException {
  4 5429        Intent intent = new Intent();
  5 5430        Intent baseIntent = intent;
  6 5431        boolean hasIntentInfo = false;
  7 5432
  8 5433        Uri data = null;
  9 5434        String type = null;
 10 5435
 11 5436        String opt;
 12 5437        while ((opt=cmd.getNextOption()) != null) {
 13 5438            switch (opt) {
 14 5439                case "-a":
 15 5440                    intent.setAction(cmd.getNextArgRequired());
 16 5441                    if (intent == baseIntent) {
 17 5442                        hasIntentInfo = true;
 18 5443                    }
 19 5444                    break;
 20 5445                case "-d":
 21 5446                    data = Uri.parse(cmd.getNextArgRequired());
 22 5447                    if (intent == baseIntent) {
 23 5448                        hasIntentInfo = true;
 24 5449                    }
 25 5450                    break;
 26 5451                case "-t":
 27 5452                    type = cmd.getNextArgRequired();
 28 5453                    if (intent == baseIntent) {
 29 5454                        hasIntentInfo = true;
 30 5455                    }
 31 5456                    break;
 32 5457                case "-c":
 33 5458                    intent.addCategory(cmd.getNextArgRequired());
 34 5459                    if (intent == baseIntent) {
 35 5460                        hasIntentInfo = true;
 36 5461                    }
 37 5462                    break;
 38 5463                case "-e":
 39 5464                case "--es": {
 40 5465                    String key = cmd.getNextArgRequired();
 41 5466                    String value = cmd.getNextArgRequired();
 42 5467                    intent.putExtra(key, value);
 43 5468                }
 44 5469                break;
 45 5470                case "--esn": {
 46 5471                    String key = cmd.getNextArgRequired();
 47 5472                    intent.putExtra(key, (String) null);
 48 5473                }
 49 5474                break;
 50 5475                case "--ei": {
 51 5476                    String key = cmd.getNextArgRequired();
 52 5477                    String value = cmd.getNextArgRequired();
 53 5478                    intent.putExtra(key, Integer.decode(value));
 54 5479                }
 55 5480                break;
 56 5481                case "--eu": {
 57 5482                    String key = cmd.getNextArgRequired();
 58 5483                    String value = cmd.getNextArgRequired();
 59 5484                    intent.putExtra(key, Uri.parse(value));
 60 5485                }
 61 5486                break;
 62 5487                case "--ecn": {
 63 5488                    String key = cmd.getNextArgRequired();
 64 5489                    String value = cmd.getNextArgRequired();
 65 5490                    ComponentName cn = ComponentName.unflattenFromString(value);
 66 5491                    if (cn == null)
 67 5492                        throw new IllegalArgumentException("Bad component name: " + value);
 68 5493                    intent.putExtra(key, cn);
 69 5494                }
 70 5495                break;
 71 5496                case "--eia": {
 72 5497                    String key = cmd.getNextArgRequired();
 73 5498                    String value = cmd.getNextArgRequired();
 74 5499                    String[] strings = value.split(",");
 75 5500                    int[] list = new int[strings.length];
 76 5501                    for (int i = 0; i < strings.length; i++) {
 77 5502                        list[i] = Integer.decode(strings[i]);
 78 5503                    }
 79 5504                    intent.putExtra(key, list);
 80 5505                }
 81 5506                break;
 82 5507                case "--eial": {
 83 5508                    String key = cmd.getNextArgRequired();
 84 5509                    String value = cmd.getNextArgRequired();
 85 5510                    String[] strings = value.split(",");
 86 5511                    ArrayList<Integer> list = new ArrayList<>(strings.length);
 87 5512                    for (int i = 0; i < strings.length; i++) {
 88 5513                        list.add(Integer.decode(strings[i]));
 89 5514                    }
 90 5515                    intent.putExtra(key, list);
 91 5516                }
 92 5517                break;
 93 5518                case "--el": {
 94 5519                    String key = cmd.getNextArgRequired();
 95 5520                    String value = cmd.getNextArgRequired();
 96 5521                    intent.putExtra(key, Long.valueOf(value));
 97 5522                }
 98 5523                break;
 99 5524                case "--ela": {
100 5525                    String key = cmd.getNextArgRequired();
101 5526                    String value = cmd.getNextArgRequired();
102 5527                    String[] strings = value.split(",");
103 5528                    long[] list = new long[strings.length];
104 5529                    for (int i = 0; i < strings.length; i++) {
105 5530                        list[i] = Long.valueOf(strings[i]);
106 5531                    }
107 5532                    intent.putExtra(key, list);
108 5533                    hasIntentInfo = true;
109 5534                }
110 5535                break;
111 5536                case "--elal": {
112 5537                    String key = cmd.getNextArgRequired();
113 5538                    String value = cmd.getNextArgRequired();
114 5539                    String[] strings = value.split(",");
115 5540                    ArrayList<Long> list = new ArrayList<>(strings.length);
116 5541                    for (int i = 0; i < strings.length; i++) {
117 5542                        list.add(Long.valueOf(strings[i]));
118 5543                    }
119 5544                    intent.putExtra(key, list);
120 5545                    hasIntentInfo = true;
121 5546                }
122 5547                break;
123 5548                case "--ef": {
124 5549                    String key = cmd.getNextArgRequired();
125 5550                    String value = cmd.getNextArgRequired();
126 5551                    intent.putExtra(key, Float.valueOf(value));
127 5552                    hasIntentInfo = true;
128 5553                }
129 5554                break;
130 5555                case "--efa": {
131 5556                    String key = cmd.getNextArgRequired();
132 5557                    String value = cmd.getNextArgRequired();
133 5558                    String[] strings = value.split(",");
134 5559                    float[] list = new float[strings.length];
135 5560                    for (int i = 0; i < strings.length; i++) {
136 5561                        list[i] = Float.valueOf(strings[i]);
137 5562                    }
138 5563                    intent.putExtra(key, list);
139 5564                    hasIntentInfo = true;
140 5565                }
141 5566                break;
142 5567                case "--efal": {
143 5568                    String key = cmd.getNextArgRequired();
144 5569                    String value = cmd.getNextArgRequired();
145 5570                    String[] strings = value.split(",");
146 5571                    ArrayList<Float> list = new ArrayList<>(strings.length);
147 5572                    for (int i = 0; i < strings.length; i++) {
148 5573                        list.add(Float.valueOf(strings[i]));
149 5574                    }
150 5575                    intent.putExtra(key, list);
151 5576                    hasIntentInfo = true;
152 5577                }
153 5578                break;
154 5579                case "--esa": {
155 5580                    String key = cmd.getNextArgRequired();
156 5581                    String value = cmd.getNextArgRequired();
157 5582                    // Split on commas unless they are preceeded by an escape.
158 5583                    // The escape character must be escaped for the string and
159 5584                    // again for the regex, thus four escape characters become one.
160 5585                    String[] strings = value.split("(?<!\\\\),");
161 5586                    intent.putExtra(key, strings);
162 5587                    hasIntentInfo = true;
163 5588                }
164 5589                break;
165 5590                case "--esal": {
166 5591                    String key = cmd.getNextArgRequired();
167 5592                    String value = cmd.getNextArgRequired();
168 5593                    // Split on commas unless they are preceeded by an escape.
169 5594                    // The escape character must be escaped for the string and
170 5595                    // again for the regex, thus four escape characters become one.
171 5596                    String[] strings = value.split("(?<!\\\\),");
172 5597                    ArrayList<String> list = new ArrayList<>(strings.length);
173 5598                    for (int i = 0; i < strings.length; i++) {
174 5599                        list.add(strings[i]);
175 5600                    }
176 5601                    intent.putExtra(key, list);
177 5602                    hasIntentInfo = true;
178 5603                }
179 5604                break;
180 5605                case "--ez": {
181 5606                    String key = cmd.getNextArgRequired();
182 5607                    String value = cmd.getNextArgRequired().toLowerCase();
183 5608                    // Boolean.valueOf() results in false for anything that is not "true", which is
184 5609                    // error-prone in shell commands
185 5610                    boolean arg;
186 5611                    if ("true".equals(value) || "t".equals(value)) {
187 5612                        arg = true;
188 5613                    } else if ("false".equals(value) || "f".equals(value)) {
189 5614                        arg = false;
190 5615                    } else {
191 5616                        try {
192 5617                            arg = Integer.decode(value) != 0;
193 5618                        } catch (NumberFormatException ex) {
194 5619                            throw new IllegalArgumentException("Invalid boolean value: " + value);
195 5620                        }
196 5621                    }
197 5622
198 5623                    intent.putExtra(key, arg);
199 5624                }
200 5625                break;
201 5626                case "-n": {
202 5627                    String str = cmd.getNextArgRequired();
203 5628                    ComponentName cn = ComponentName.unflattenFromString(str);
204 5629                    if (cn == null)
205 5630                        throw new IllegalArgumentException("Bad component name: " + str);
206 5631                    intent.setComponent(cn);
207 5632                    if (intent == baseIntent) {
208 5633                        hasIntentInfo = true;
209 5634                    }
210 5635                }
211 5636                break;
212 5637                case "-p": {
213 5638                    String str = cmd.getNextArgRequired();
214 5639                    intent.setPackage(str);
215 5640                    if (intent == baseIntent) {
216 5641                        hasIntentInfo = true;
217 5642                    }
218 5643                }
219 5644                break;
220 5645                case "-f":
221 5646                    String str = cmd.getNextArgRequired();
222 5647                    intent.setFlags(Integer.decode(str).intValue());
223 5648                    break;
224 5649                case "--grant-read-uri-permission":
225 5650                    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
226 5651                    break;
227 5652                case "--grant-write-uri-permission":
228 5653                    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
229 5654                    break;
230 5655                case "--grant-persistable-uri-permission":
231 5656                    intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
232 5657                    break;
233 5658                case "--grant-prefix-uri-permission":
234 5659                    intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
235 5660                    break;
236 5661                case "--exclude-stopped-packages":
237 5662                    intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
238 5663                    break;
239 5664                case "--include-stopped-packages":
240 5665                    intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
241 5666                    break;
242 5667                case "--debug-log-resolution":
243 5668                    intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
244 5669                    break;
245 5670                case "--activity-brought-to-front":
246 5671                    intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
247 5672                    break;
248 5673                case "--activity-clear-top":
249 5674                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
250 5675                    break;
251 5676                case "--activity-clear-when-task-reset":
252 5677                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
253 5678                    break;
254 5679                case "--activity-exclude-from-recents":
255 5680                    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
256 5681                    break;
257 5682                case "--activity-launched-from-history":
258 5683                    intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
259 5684                    break;
260 5685                case "--activity-multiple-task":
261 5686                    intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
262 5687                    break;
263 5688                case "--activity-no-animation":
264 5689                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
265 5690                    break;
266 5691                case "--activity-no-history":
267 5692                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
268 5693                    break;
269 5694                case "--activity-no-user-action":
270 5695                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
271 5696                    break;
272 5697                case "--activity-previous-is-top":
273 5698                    intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
274 5699                    break;
275 5700                case "--activity-reorder-to-front":
276 5701                    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
277 5702                    break;
278 5703                case "--activity-reset-task-if-needed":
279 5704                    intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
280 5705                    break;
281 5706                case "--activity-single-top":
282 5707                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
283 5708                    break;
284 5709                case "--activity-clear-task":
285 5710                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
286 5711                    break;
287 5712                case "--activity-task-on-home":
288 5713                    intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
289 5714                    break;
290 5715                case "--receiver-registered-only":
291 5716                    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
292 5717                    break;
293 5718                case "--receiver-replace-pending":
294 5719                    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
295 5720                    break;
296 5721                case "--receiver-foreground":
297 5722                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
298 5723                    break;
299 5724                case "--selector":
300 5725                    intent.setDataAndType(data, type);
301 5726                    intent = new Intent();
302 5727                    break;
303 5728                default:
304 5729                    if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
305 5730                        // Okay, caller handled this option.
306 5731                    } else {
307 5732                        throw new IllegalArgumentException("Unknown option: " + opt);
308 5733                    }
309 5734                    break;
310 5735            }
311 5736        }
312 5737        intent.setDataAndType(data, type);
313 5738
314 5739        final boolean hasSelector = intent != baseIntent;
315 5740        if (hasSelector) {
316 5741            // A selector was specified; fix up.
317 5742            baseIntent.setSelector(intent);
318 5743            intent = baseIntent;
319 5744        }
320 5745
321 5746        String arg = cmd.getNextArg();
322 5747        baseIntent = null;
323 5748        if (arg == null) {
324 5749            if (hasSelector) {
325 5750                // If a selector has been specified, and no arguments
326 5751                // have been supplied for the main Intent, then we can
327 5752                // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
328 5753                // need to have a component name specified yet, the
329 5754                // selector will take care of that.
330 5755                baseIntent = new Intent(Intent.ACTION_MAIN);
331 5756                baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
332 5757            }
333 5758        } else if (arg.indexOf(':') >= 0) {
334 5759            // The argument is a URI.  Fully parse it, and use that result
335 5760            // to fill in any data not specified so far.
336 5761            baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
337 5762                    | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
338 5763        } else if (arg.indexOf('/') >= 0) {
339 5764            // The argument is a component name.  Build an Intent to launch
340 5765            // it.
341 5766            baseIntent = new Intent(Intent.ACTION_MAIN);
342 5767            baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
343 5768            baseIntent.setComponent(ComponentName.unflattenFromString(arg));
344 5769        } else {
345 5770            // Assume the argument is a package name.
346 5771            baseIntent = new Intent(Intent.ACTION_MAIN);
347 5772            baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
348 5773            baseIntent.setPackage(arg);
349 5774        }
350 5775        if (baseIntent != null) {
351 5776            Bundle extras = intent.getExtras();
352 5777            intent.replaceExtras((Bundle)null);
353 5778            Bundle uriExtras = baseIntent.getExtras();
354 5779            baseIntent.replaceExtras((Bundle)null);
355 5780            if (intent.getAction() != null && baseIntent.getCategories() != null) {
356 5781                HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
357 5782                for (String c : cats) {
358 5783                    baseIntent.removeCategory(c);
359 5784                }
360 5785            }
361 5786            intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
362 5787            if (extras == null) {
363 5788                extras = uriExtras;
364 5789            } else if (uriExtras != null) {
365 5790                uriExtras.putAll(extras);
366 5791                extras = uriExtras;
367 5792            }
368 5793            intent.replaceExtras(extras);
369 5794            hasIntentInfo = true;
370 5795        }
371 5796
372 5797        if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
373 5798        return intent;
374 5799    }
375 5800

printIntentArgsHelp打印命令的選項和參數幫助

 

 1 5801    /** @hide */
 2 5802    public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
 3 5803        final String[] lines = new String[] {
 4 5804                "<INTENT> specifications include these flags and arguments:",
 5 5805                "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
 6 5806                "    [-c <CATEGORY> [-c <CATEGORY>] ...]",
 7 5807                "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
 8 5808                "    [--esn <EXTRA_KEY> ...]",
 9 5809                "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
10 5810                "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
11 5811                "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
12 5812                "    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
13 5813                "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
14 5814                "    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
15 5815                "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
16 5816                "        (mutiple extras passed as Integer[])",
17 5817                "    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
18 5818                "        (mutiple extras passed as List<Integer>)",
19 5819                "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
20 5820                "        (mutiple extras passed as Long[])",
21 5821                "    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
22 5822                "        (mutiple extras passed as List<Long>)",
23 5823                "    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
24 5824                "        (mutiple extras passed as Float[])",
25 5825                "    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
26 5826                "        (mutiple extras passed as List<Float>)",
27 5827                "    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
28 5828                "        (mutiple extras passed as String[]; to embed a comma into a string,",
29 5829                "         escape it using \"\\,\")",
30 5830                "    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
31 5831                "        (mutiple extras passed as List<String>; to embed a comma into a string,",
32 5832                "         escape it using \"\\,\")",
33 5833                "    [--f <FLAG>]",
34 5834                "    [--grant-read-uri-permission] [--grant-write-uri-permission]",
35 5835                "    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
36 5836                "    [--debug-log-resolution] [--exclude-stopped-packages]",
37 5837                "    [--include-stopped-packages]",
38 5838                "    [--activity-brought-to-front] [--activity-clear-top]",
39 5839                "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
40 5840                "    [--activity-launched-from-history] [--activity-multiple-task]",
41 5841                "    [--activity-no-animation] [--activity-no-history]",
42 5842                "    [--activity-no-user-action] [--activity-previous-is-top]",
43 5843                "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
44 5844                "    [--activity-single-top] [--activity-clear-task]",
45 5845                "    [--activity-task-on-home]",
46 5846                "    [--receiver-registered-only] [--receiver-replace-pending]",
47 5847                "    [--receiver-foreground]",
48 5848                "    [--selector]",
49 5849                "    [<URI> | <PACKAGE> | <COMPONENT>]"
50 5850        };
51 5851        for (String line : lines) {
52 5852            pw.print(prefix);
53 5853            pw.println(line);
54 5854        }
55 5855    }
56 5856

函數getAction返回action

 1 5857    /**
 2 5858     * Retrieve the general action to be performed, such as
 3 5859     * {@link #ACTION_VIEW}.  The action describes the general way the rest of
 4 5860     * the information in the intent should be interpreted -- most importantly,
 5 5861     * what to do with the data returned by {@link #getData}.
 6 5862     *
 7 5863     * @return The action of this intent or null if none is specified.
 8 5864     *
 9 5865     * @see #setAction
10 5866     */
11 5867    public String getAction() {
12 5868        return mAction;
13 5869    }

getData返回data

 1 5871    /**
 2 5872     * Retrieve data this intent is operating on.  This URI specifies the name
 3 5873     * of the data; often it uses the content: scheme, specifying data in a
 4 5874     * content provider.  Other schemes may be handled by specific activities,
 5 5875     * such as http: by the web browser.
 6 5876     *
 7 5877     * @return The URI of the data this intent is targeting or null.
 8 5878     *
 9 5879     * @see #getScheme
10 5880     * @see #setData
11 5881     */
12 5882    public Uri getData() {
13 5883        return mData;
14 5884    }

getDataString把Uri類轉換爲string

1 5886    /**
2 5887     * The same as {@link #getData()}, but returns the URI as an encoded
3 5888     * String.
4 5889     */
5 5890    public String getDataString() {
6 5891        return mData != null ? mData.toString() : null;
7 5892    }

getDataScheme返回協議名

 1 5894    /**
 2 5895     * Return the scheme portion of the intent's data.  If the data is null or
 3 5896     * does not include a scheme, null is returned.  Otherwise, the scheme
 4 5897     * prefix without the final ':' is returned, i.e. "http".
 5 5898     *
 6 5899     * <p>This is the same as calling getData().getScheme() (and checking for
 7 5900     * null data).
 8 5901     *
 9 5902     * @return The scheme of this intent.
10 5903     *
11 5904     * @see #getData
12 5905     */
13 5906    public String getScheme() {
14 5907        return mData != null ? mData.getScheme() : null;
15 5908    }

getType返回MIME type

 1 5910    /**
 2 5911     * Retrieve any explicit MIME type included in the intent.  This is usually
 3 5912     * null, as the type is determined by the intent data.
 4 5913     *
 5 5914     * @return If a type was manually set, it is returned; else null is
 6 5915     *         returned.
 7 5916     *
 8 5917     * @see #resolveType(ContentResolver)
 9 5918     * @see #setType
10 5919     */
11 5920    public String getType() {
12 5921        return mType;
13 5922    }

 resolveType和resolveTypeIfNeeded會返回當前的MIME type,讓ContentResolver根據mData來作

 1 5924    /**
 2 5925     * Return the MIME data type of this intent.  If the type field is
 3 5926     * explicitly set, that is simply returned.  Otherwise, if the data is set,
 4 5927     * the type of that data is returned.  If neither fields are set, a null is
 5 5928     * returned.
 6 5929     *
 7 5930     * @return The MIME type of this intent.
 8 5931     *
 9 5932     * @see #getType
10 5933     * @see #resolveType(ContentResolver)
11 5934     */
12 5935    public String resolveType(Context context) {
13 5936        return resolveType(context.getContentResolver());
14 5937    }
15 5938
16 5939    /**
17 5940     * Return the MIME data type of this intent.  If the type field is
18 5941     * explicitly set, that is simply returned.  Otherwise, if the data is set,
19 5942     * the type of that data is returned.  If neither fields are set, a null is
20 5943     * returned.
21 5944     *
22 5945     * @param resolver A ContentResolver that can be used to determine the MIME
23 5946     *                 type of the intent's data.
24 5947     *
25 5948     * @return The MIME type of this intent.
26 5949     *
27 5950     * @see #getType
28 5951     * @see #resolveType(Context)
29 5952     */
30 5953    public String resolveType(ContentResolver resolver) {
31 5954        if (mType != null) {
32 5955            return mType;
33 5956        }
34 5957        if (mData != null) {
35 5958            if ("content".equals(mData.getScheme())) {
36 5959                return resolver.getType(mData);
37 5960            }
38 5961        }
39 5962        return null;
40 5963    }
41 5964
42 5965    /**
43 5966     * Return the MIME data type of this intent, only if it will be needed for
44 5967     * intent resolution.  This is not generally useful for application code;
45 5968     * it is used by the frameworks for communicating with back-end system
46 5969     * services.
47 5970     *
48 5971     * @param resolver A ContentResolver that can be used to determine the MIME
49 5972     *                 type of the intent's data.
50 5973     *
51 5974     * @return The MIME type of this intent, or null if it is unknown or not
52 5975     *         needed.
53 5976     */
54 5977    public String resolveTypeIfNeeded(ContentResolver resolver) {
55 5978        if (mComponent != null) {
56 5979            return mType;
57 5980        }
58 5981        return resolveType(resolver);
59 5982    }

hasCategory和getCategories判斷是否包含某個category和返回categories

 1 5984    /**
 2 5985     * Check if a category exists in the intent.
 3 5986     *
 4 5987     * @param category The category to check.
 5 5988     *
 6 5989     * @return boolean True if the intent contains the category, else false.
 7 5990     *
 8 5991     * @see #getCategories
 9 5992     * @see #addCategory
10 5993     */
11 5994    public boolean hasCategory(String category) {
12 5995        return mCategories != null && mCategories.contains(category);
13 5996    }
14 5997
15 5998    /**
16 5999     * Return the set of all categories in the intent.  If there are no categories,
17 6000     * returns NULL.
18 6001     *
19 6002     * @return The set of categories you can examine.  Do not modify!
20 6003     *
21 6004     * @see #hasCategory
22 6005     * @see #addCategory
23 6006     */
24 6007    public Set<String> getCategories() {
25 6008        return mCategories;
26 6009    }

getSelector獲取mSelector

1 6011    /**
2 6012     * Return the specific selector associated with this Intent.  If there is
3 6013     * none, returns null.  See {@link #setSelector} for more information.
4 6014     *
5 6015     * @see #setSelector
6 6016     */
7 6017    public Intent getSelector() {
8 6018        return mSelector;
9 6019    }

getClipData返回mClipData

1 6021    /**
2 6022     * Return the {@link ClipData} associated with this Intent.  If there is
3 6023     * none, returns null.  See {@link #setClipData} for more information.
4 6024     *
5 6025     * @see #setClipData
6 6026     */
7 6027    public ClipData getClipData() {
8 6028        return mClipData;
9 6029    }

getContentUserHint返回mContentUserHint

1 6031    /** @hide */
2 6032    public int getContentUserHint() {
3 6033        return mContentUserHint;
4 6034    }

setExtrasClassloader設置mExtras的ClassLoader

 1 6036    /**
 2 6037     * Sets the ClassLoader that will be used when unmarshalling
 3 6038     * any Parcelable values from the extras of this Intent.
 4 6039     *
 5 6040     * @param loader a ClassLoader, or null to use the default loader
 6 6041     * at the time of unmarshalling.
 7 6042     */
 8 6043    public void setExtrasClassLoader(ClassLoader loader) {
 9 6044        if (mExtras != null) {
10 6045            mExtras.setClassLoader(loader);
11 6046        }
12 6047    }

hasExtra和hasFileDescriptors調用Bundle的containsKey和hasFileDescriptros

 1 6049    /**
 2 6050     * Returns true if an extra value is associated with the given name.
 3 6051     * @param name the extra's name
 4 6052     * @return true if the given extra is present.
 5 6053     */
 6 6054    public boolean hasExtra(String name) {
 7 6055        return mExtras != null && mExtras.containsKey(name);
 8 6056    }
 9 6057
10 6058    /**
11 6059     * Returns true if the Intent's extras contain a parcelled file descriptor.
12 6060     * @return true if the Intent contains a parcelled file descriptor.
13 6061     */
14 6062    public boolean hasFileDescriptors() {
15 6063        return mExtras != null && mExtras.hasFileDescriptors();
16 6064    }

setAllowFds和setDefusable調用Bunde的setAllowFds和setDefusable

 1 6066    /** {@hide} */
 2 6067    public void setAllowFds(boolean allowFds) {
 3 6068        if (mExtras != null) {
 4 6069            mExtras.setAllowFds(allowFds);
 5 6070        }
 6 6071    }
 7 6072
 8 6073    /** {@hide} */
 9 6074    public void setDefusable(boolean defusable) {
10 6075        if (mExtras != null) {
11 6076            mExtras.setDefusable(defusable);
12 6077        }
13 6078    }
14 6079

getExtra返回Object對象, 沒找到返回參數裏的默認值

 1 6530    /**
 2 6531     * Retrieve extended data from the intent.
 3 6532     *
 4 6533     * @param name The name of the desired item.
 5 6534     * @param defaultValue The default value to return in case no item is
 6 6535     * associated with the key 'name'
 7 6536     *
 8 6537     * @return the value of an item that previously added with putExtra()
 9 6538     * or defaultValue if none was found.
10 6539     *
11 6540     * @see #putExtra
12 6541     *
13 6542     * @deprecated
14 6543     * @hide
15 6544     */
16 6545    @Deprecated
17 6546    public Object getExtra(String name, Object defaultValue) {
18 6547        Object result = defaultValue;
19 6548        if (mExtras != null) {
20 6549            Object result2 = mExtras.get(name);
21 6550            if (result2 != null) {
22 6551                result = result2;
23 6552            }
24 6553        }
25 6554
26 6555        return result;
27 6556    }

還有一個默認值爲NULL的版本

 1 6080    /**
 2 6081     * Retrieve extended data from the intent.
 3 6082     *
 4 6083     * @param name The name of the desired item.
 5 6084     *
 6 6085     * @return the value of an item that previously added with putExtra()
 7 6086     * or null if none was found.
 8 6087     *
 9 6088     * @deprecated
10 6089     * @hide
11 6090     */
12 6091    @Deprecated
13 6092    public Object getExtra(String name) {
14 6093        return getExtra(name, null);
15 6094    }

getBooleanExtra,getByteExtra,getShortExtra,getCharExtra,getIntExtra,getLongExtra,getFloatExtra,getDoubleExtra,getStringExtra,getCharSequenceExtra,getParcelableExtra,getParcelableArrayExtra,getParcelableArrayListExtra,getSeriableExtra,getIntegerArrayListExtra,getStringArrayListExtra,getCharSequenceArrayList,getBooleanArrayExtra,getByteArrayExtra,getShortArrayExtra,getIntArrayExtra,getLongArrayExtra,getFloatArrayExtra,getDoubleArrayExtra,getStrignArrayExtra,getCharSequenceArrayExtra,getBundleExtra,getIBinderExtra分別調用Bundle的相應方法

  1 6096    /**
  2 6097     * Retrieve extended data from the intent.
  3 6098     *
  4 6099     * @param name The name of the desired item.
  5 6100     * @param defaultValue the value to be returned if no value of the desired
  6 6101     * type is stored with the given name.
  7 6102     *
  8 6103     * @return the value of an item that previously added with putExtra()
  9 6104     * or the default value if none was found.
 10 6105     *
 11 6106     * @see #putExtra(String, boolean)
 12 6107     */
 13 6108    public boolean getBooleanExtra(String name, boolean defaultValue) {
 14 6109        return mExtras == null ? defaultValue :
 15 6110            mExtras.getBoolean(name, defaultValue);
 16 6111    }
 17 6112
 18 6113    /**
 19 6114     * Retrieve extended data from the intent.
 20 6115     *
 21 6116     * @param name The name of the desired item.
 22 6117     * @param defaultValue the value to be returned if no value of the desired
 23 6118     * type is stored with the given name.
 24 6119     *
 25 6120     * @return the value of an item that previously added with putExtra()
 26 6121     * or the default value if none was found.
 27 6122     *
 28 6123     * @see #putExtra(String, byte)
 29 6124     */
 30 6125    public byte getByteExtra(String name, byte defaultValue) {
 31 6126        return mExtras == null ? defaultValue :
 32 6127            mExtras.getByte(name, defaultValue);
 33 6128    }
 34 6129
 35 6130    /**
 36 6131     * Retrieve extended data from the intent.
 37 6132     *
 38 6133     * @param name The name of the desired item.
 39 6134     * @param defaultValue the value to be returned if no value of the desired
 40 6135     * type is stored with the given name.
 41 6136     *
 42 6137     * @return the value of an item that previously added with putExtra()
 43 6138     * or the default value if none was found.
 44 6139     *
 45 6140     * @see #putExtra(String, short)
 46 6141     */
 47 6142    public short getShortExtra(String name, short defaultValue) {
 48 6143        return mExtras == null ? defaultValue :
 49 6144            mExtras.getShort(name, defaultValue);
 50 6145    }
 51 6146
 52 6147    /**
 53 6148     * Retrieve extended data from the intent.
 54 6149     *
 55 6150     * @param name The name of the desired item.
 56 6151     * @param defaultValue the value to be returned if no value of the desired
 57 6152     * type is stored with the given name.
 58 6153     *
 59 6154     * @return the value of an item that previously added with putExtra()
 60 6155     * or the default value if none was found.
 61 6156     *
 62 6157     * @see #putExtra(String, char)
 63 6158     */
 64 6159    public char getCharExtra(String name, char defaultValue) {
 65 6160        return mExtras == null ? defaultValue :
 66 6161            mExtras.getChar(name, defaultValue);
 67 6162    }
 68 6163
 69 6164    /**
 70 6165     * Retrieve extended data from the intent.
 71 6166     *
 72 6167     * @param name The name of the desired item.
 73 6168     * @param defaultValue the value to be returned if no value of the desired
 74 6169     * type is stored with the given name.
 75 6170     *
 76 6171     * @return the value of an item that previously added with putExtra()
 77 6172     * or the default value if none was found.
 78 6173     *
 79 6174     * @see #putExtra(String, int)
 80 6175     */
 81 6176    public int getIntExtra(String name, int defaultValue) {
 82 6177        return mExtras == null ? defaultValue :
 83 6178            mExtras.getInt(name, defaultValue);
 84 6179    }
 85 6180
 86 6181    /**
 87 6182     * Retrieve extended data from the intent.
 88 6183     *
 89 6184     * @param name The name of the desired item.
 90 6185     * @param defaultValue the value to be returned if no value of the desired
 91 6186     * type is stored with the given name.
 92 6187     *
 93 6188     * @return the value of an item that previously added with putExtra()
 94 6189     * or the default value if none was found.
 95 6190     *
 96 6191     * @see #putExtra(String, long)
 97 6192     */
 98 6193    public long getLongExtra(String name, long defaultValue) {
 99 6194        return mExtras == null ? defaultValue :
100 6195            mExtras.getLong(name, defaultValue);
101 6196    }
102 6197
103 6198    /**
104 6199     * Retrieve extended data from the intent.
105 6200     *
106 6201     * @param name The name of the desired item.
107 6202     * @param defaultValue the value to be returned if no value of the desired
108 6203     * type is stored with the given name.
109 6204     *
110 6205     * @return the value of an item that previously added with putExtra(),
111 6206     * or the default value if no such item is present
112 6207     *
113 6208     * @see #putExtra(String, float)
114 6209     */
115 6210    public float getFloatExtra(String name, float defaultValue) {
116 6211        return mExtras == null ? defaultValue :
117 6212            mExtras.getFloat(name, defaultValue);
118 6213    }
119 6214
120 6215    /**
121 6216     * Retrieve extended data from the intent.
122 6217     *
123 6218     * @param name The name of the desired item.
124 6219     * @param defaultValue the value to be returned if no value of the desired
125 6220     * type is stored with the given name.
126 6221     *
127 6222     * @return the value of an item that previously added with putExtra()
128 6223     * or the default value if none was found.
129 6224     *
130 6225     * @see #putExtra(String, double)
131 6226     */
132 6227    public double getDoubleExtra(String name, double defaultValue) {
133 6228        return mExtras == null ? defaultValue :
134 6229            mExtras.getDouble(name, defaultValue);
135 6230    }
136 6231
137 6232    /**
138 6233     * Retrieve extended data from the intent.
139 6234     *
140 6235     * @param name The name of the desired item.
141 6236     *
142 6237     * @return the value of an item that previously added with putExtra()
143 6238     * or null if no String value was found.
144 6239     *
145 6240     * @see #putExtra(String, String)
146 6241     */
147 6242    public String getStringExtra(String name) {
148 6243        return mExtras == null ? null : mExtras.getString(name);
149 6244    }
150 6245
151 6246    /**
152 6247     * Retrieve extended data from the intent.
153 6248     *
154 6249     * @param name The name of the desired item.
155 6250     *
156 6251     * @return the value of an item that previously added with putExtra()
157 6252     * or null if no CharSequence value was found.
158 6253     *
159 6254     * @see #putExtra(String, CharSequence)
160 6255     */
161 6256    public CharSequence getCharSequenceExtra(String name) {
162 6257        return mExtras == null ? null : mExtras.getCharSequence(name);
163 6258    }
164 6259
165 6260    /**
166 6261     * Retrieve extended data from the intent.
167 6262     *
168 6263     * @param name The name of the desired item.
169 6264     *
170 6265     * @return the value of an item that previously added with putExtra()
171 6266     * or null if no Parcelable value was found.
172 6267     *
173 6268     * @see #putExtra(String, Parcelable)
174 6269     */
175 6270    public <T extends Parcelable> T getParcelableExtra(String name) {
176 6271        return mExtras == null ? null : mExtras.<T>getParcelable(name);
177 6272    }
178 6273
179 6274    /**
180 6275     * Retrieve extended data from the intent.
181 6276     *
182 6277     * @param name The name of the desired item.
183 6278     *
184 6279     * @return the value of an item that previously added with putExtra()
185 6280     * or null if no Parcelable[] value was found.
186 6281     *
187 6282     * @see #putExtra(String, Parcelable[])
188 6283     */
189 6284    public Parcelable[] getParcelableArrayExtra(String name) {
190 6285        return mExtras == null ? null : mExtras.getParcelableArray(name);
191 6286    }
192 6287
193 6288    /**
194 6289     * Retrieve extended data from the intent.
195 6290     *
196 6291     * @param name The name of the desired item.
197 6292     *
198 6293     * @return the value of an item that previously added with putExtra()
199 6294     * or null if no ArrayList<Parcelable> value was found.
200 6295     *
201 6296     * @see #putParcelableArrayListExtra(String, ArrayList)
202 6297     */
203 6298    public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
204 6299        return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
205 6300    }
206 6301
207 6302    /**
208 6303     * Retrieve extended data from the intent.
209 6304     *
210 6305     * @param name The name of the desired item.
211 6306     *
212 6307     * @return the value of an item that previously added with putExtra()
213 6308     * or null if no Serializable value was found.
214 6309     *
215 6310     * @see #putExtra(String, Serializable)
216 6311     */
217 6312    public Serializable getSerializableExtra(String name) {
218 6313        return mExtras == null ? null : mExtras.getSerializable(name);
219 6314    }
220 6315
221 6316    /**
222 6317     * Retrieve extended data from the intent.
223 6318     *
224 6319     * @param name The name of the desired item.
225 6320     *
226 6321     * @return the value of an item that previously added with putExtra()
227 6322     * or null if no ArrayList<Integer> value was found.
228 6323     *
229 6324     * @see #putIntegerArrayListExtra(String, ArrayList)
230 6325     */
231 6326    public ArrayList<Integer> getIntegerArrayListExtra(String name) {
232 6327        return mExtras == null ? null : mExtras.getIntegerArrayList(name);
233 6328    }
234 6329
235 6330    /**
236 6331     * Retrieve extended data from the intent.
237 6332     *
238 6333     * @param name The name of the desired item.
239 6334     *
240 6335     * @return the value of an item that previously added with putExtra()
241 6336     * or null if no ArrayList<String> value was found.
242 6337     *
243 6338     * @see #putStringArrayListExtra(String, ArrayList)
244 6339     */
245 6340    public ArrayList<String> getStringArrayListExtra(String name) {
246 6341        return mExtras == null ? null : mExtras.getStringArrayList(name);
247 6342    }
248 6343
249 6344    /**
250 6345     * Retrieve extended data from the intent.
251 6346     *
252 6347     * @param name The name of the desired item.
253 6348     *
254 6349     * @return the value of an item that previously added with putExtra()
255 6350     * or null if no ArrayList<CharSequence> value was found.
256 6351     *
257 6352     * @see #putCharSequenceArrayListExtra(String, ArrayList)
258 6353     */
259 6354    public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
260 6355        return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
261 6356    }
262 6357
263 6358    /**
264 6359     * Retrieve extended data from the intent.
265 6360     *
266 6361     * @param name The name of the desired item.
267 6362     *
268 6363     * @return the value of an item that previously added with putExtra()
269 6364     * or null if no boolean array value was found.
270 6365     *
271 6366     * @see #putExtra(String, boolean[])
272 6367     */
273 6368    public boolean[] getBooleanArrayExtra(String name) {
274 6369        return mExtras == null ? null : mExtras.getBooleanArray(name);
275 6370    }
276 6371
277 6372    /**
278 6373     * Retrieve extended data from the intent.
279 6374     *
280 6375     * @param name The name of the desired item.
281 6376     *
282 6377     * @return the value of an item that previously added with putExtra()
283 6378     * or null if no byte array value was found.
284 6379     *
285 6380     * @see #putExtra(String, byte[])
286 6381     */
287 6382    public byte[] getByteArrayExtra(String name) {
288 6383        return mExtras == null ? null : mExtras.getByteArray(name);
289 6384    }
290 6385
291 6386    /**
292 6387     * Retrieve extended data from the intent.
293 6388     *
294 6389     * @param name The name of the desired item.
295 6390     *
296 6391     * @return the value of an item that previously added with putExtra()
297 6392     * or null if no short array value was found.
298 6393     *
299 6394     * @see #putExtra(String, short[])
300 6395     */
301 6396    public short[] getShortArrayExtra(String name) {
302 6397        return mExtras == null ? null : mExtras.getShortArray(name);
303 6398    }
304 6399
305 6400    /**
306 6401     * Retrieve extended data from the intent.
307 6402     *
308 6403     * @param name The name of the desired item.
309 6404     *
310 6405     * @return the value of an item that previously added with putExtra()
311 6406     * or null if no char array value was found.
312 6407     *
313 6408     * @see #putExtra(String, char[])
314 6409     */
315 6410    public char[] getCharArrayExtra(String name) {
316 6411        return mExtras == null ? null : mExtras.getCharArray(name);
317 6412    }
318 6413
319 6414    /**
320 6415     * Retrieve extended data from the intent.
321 6416     *
322 6417     * @param name The name of the desired item.
323 6418     *
324 6419     * @return the value of an item that previously added with putExtra()
325 6420     * or null if no int array value was found.
326 6421     *
327 6422     * @see #putExtra(String, int[])
328 6423     */
329 6424    public int[] getIntArrayExtra(String name) {
330 6425        return mExtras == null ? null : mExtras.getIntArray(name);
331 6426    }
332 6427
333 6428    /**
334 6429     * Retrieve extended data from the intent.
335 6430     *
336 6431     * @param name The name of the desired item.
337 6432     *
338 6433     * @return the value of an item that previously added with putExtra()
339 6434     * or null if no long array value was found.
340 6435     *
341 6436     * @see #putExtra(String, long[])
342 6437     */
343 6438    public long[] getLongArrayExtra(String name) {
344 6439        return mExtras == null ? null : mExtras.getLongArray(name);
345 6440    }
346 6441
347 6442    /**
348 6443     * Retrieve extended data from the intent.
349 6444     *
350 6445     * @param name The name of the desired item.
351 6446     *
352 6447     * @return the value of an item that previously added with putExtra()
353 6448     * or null if no float array value was found.
354 6449     *
355 6450     * @see #putExtra(String, float[])
356 6451     */
357 6452    public float[] getFloatArrayExtra(String name) {
358 6453        return mExtras == null ? null : mExtras.getFloatArray(name);
359 6454    }
360 6455
361 6456    /**
362 6457     * Retrieve extended data from the intent.
363 6458     *
364 6459     * @param name The name of the desired item.
365 6460     *
366 6461     * @return the value of an item that previously added with putExtra()
367 6462     * or null if no double array value was found.
368 6463     *
369 6464     * @see #putExtra(String, double[])
370 6465     */
371 6466    public double[] getDoubleArrayExtra(String name) {
372 6467        return mExtras == null ? null : mExtras.getDoubleArray(name);
373 6468    }
374 6469
375 6470    /**
376 6471     * Retrieve extended data from the intent.
377 6472     *
378 6473     * @param name The name of the desired item.
379 6474     *
380 6475     * @return the value of an item that previously added with putExtra()
381 6476     * or null if no String array value was found.
382 6477     *
383 6478     * @see #putExtra(String, String[])
384 6479     */
385 6480    public String[] getStringArrayExtra(String name) {
386 6481        return mExtras == null ? null : mExtras.getStringArray(name);
387 6482    }
388 6483
389 6484    /**
390 6485     * Retrieve extended data from the intent.
391 6486     *
392 6487     * @param name The name of the desired item.
393 6488     *
394 6489     * @return the value of an item that previously added with putExtra()
395 6490     * or null if no CharSequence array value was found.
396 6491     *
397 6492     * @see #putExtra(String, CharSequence[])
398 6493     */
399 6494    public CharSequence[] getCharSequenceArrayExtra(String name) {
400 6495        return mExtras == null ? null : mExtras.getCharSequenceArray(name);
401 6496    }
402 6497
403 6498    /**
404 6499     * Retrieve extended data from the intent.
405 6500     *
406 6501     * @param name The name of the desired item.
407 6502     *
408 6503     * @return the value of an item that previously added with putExtra()
409 6504     * or null if no Bundle value was found.
410 6505     *
411 6506     * @see #putExtra(String, Bundle)
412 6507     */
413 6508    public Bundle getBundleExtra(String name) {
414 6509        return mExtras == null ? null : mExtras.getBundle(name);
415 6510    }
416 6511
417 6512    /**
418 6513     * Retrieve extended data from the intent.
419 6514     *
420 6515     * @param name The name of the desired item.
421 6516     *
422 6517     * @return the value of an item that previously added with putExtra()
423 6518     * or null if no IBinder value was found.
424 6519     *
425 6520     * @see #putExtra(String, IBinder)
426 6521     *
427 6522     * @deprecated
428 6523     * @hide
429 6524     */
430 6525    @Deprecated
431 6526    public IBinder getIBinderExtra(String name) {
432 6527        return mExtras == null ? null : mExtras.getIBinder(name);
433 6528    }
434 6529

getExtras copy一個新的mExtras

 1 6558    /**
 2 6559     * Retrieves a map of extended data from the intent.
 3 6560     *
 4 6561     * @return the map of all extras previously added with putExtra(),
 5 6562     * or null if none have been added.
 6 6563     */
 7 6564    public Bundle getExtras() {
 8 6565        return (mExtras != null)
 9 6566                ? new Bundle(mExtras)
10 6567                : null;
11 6568    }
12 6569

removeUnsafeExtras會只保留基本類型

1 6570    /**
2 6571     * Filter extras to only basic types.
3 6572     * @hide
4 6573     */
5 6574    public void removeUnsafeExtras() {
6 6575        if (mExtras != null) {
7 6576            mExtras = mExtras.filterValues();
8 6577        }
9 6578    }

getFlags獲取當前的flag

 1 6580    /**
 2 6581     * Retrieve any special flags associated with this intent.  You will
 3 6582     * normally just set them with {@link #setFlags} and let the system
 4 6583     * take the appropriate action with them.
 5 6584     *
 6 6585     * @return int The currently set flags.
 7 6586     *
 8 6587     * @see #setFlags
 9 6588     */
10 6589    public int getFlags() {
11 6590        return mFlags;
12 6591    }

isExcludingStopped看看相應的flag是否爲FLAG_EXCLUDE_STOPPED_PACKAGES。

1 6593    /** @hide */
2 6594    public boolean isExcludingStopped() {
3 6595        return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
4 6596                == FLAG_EXCLUDE_STOPPED_PACKAGES;
5 6597    }

getPackage,getComponent,getSourceBounds返回相應的私有變量

 1 6599    /**
 2 6600     * Retrieve the application package name this Intent is limited to.  When
 3 6601     * resolving an Intent, if non-null this limits the resolution to only
 4 6602     * components in the given application package.
 5 6603     *
 6 6604     * @return The name of the application package for the Intent.
 7 6605     *
 8 6606     * @see #resolveActivity
 9 6607     * @see #setPackage
10 6608     */
11 6609    public String getPackage() {
12 6610        return mPackage;
13 6611    }
14 6612
15 6613    /**
16 6614     * Retrieve the concrete component associated with the intent.  When receiving
17 6615     * an intent, this is the component that was found to best handle it (that is,
18 6616     * yourself) and will always be non-null; in all other cases it will be
19 6617     * null unless explicitly set.
20 6618     *
21 6619     * @return The name of the application component to handle the intent.
22 6620     *
23 6621     * @see #resolveActivity
24 6622     * @see #setComponent
25 6623     */
26 6624    public ComponentName getComponent() {
27 6625        return mComponent;
28 6626    }
29 6627
30 6628    /**
31 6629     * Get the bounds of the sender of this intent, in screen coordinates.  This can be
32 6630     * used as a hint to the receiver for animations and the like.  Null means that there
33 6631     * is no source bounds.
34 6632     */
35 6633    public Rect getSourceBounds() {
36 6634        return mSourceBounds;
37 6635    }
38 6636

resolveActivity返回mComponent或者經過PackageManager返回相應組件

 1 6637    /**
 2 6638     * Return the Activity component that should be used to handle this intent.
 3 6639     * The appropriate component is determined based on the information in the
 4 6640     * intent, evaluated as follows:
 5 6641     *
 6 6642     * <p>If {@link #getComponent} returns an explicit class, that is returned
 7 6643     * without any further consideration.
 8 6644     *
 9 6645     * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
10 6646     * category to be considered.
11 6647     *
12 6648     * <p>If {@link #getAction} is non-NULL, the activity must handle this
13 6649     * action.
14 6650     *
15 6651     * <p>If {@link #resolveType} returns non-NULL, the activity must handle
16 6652     * this type.
17 6653     *
18 6654     * <p>If {@link #addCategory} has added any categories, the activity must
19 6655     * handle ALL of the categories specified.
20 6656     *
21 6657     * <p>If {@link #getPackage} is non-NULL, only activity components in
22 6658     * that application package will be considered.
23 6659     *
24 6660     * <p>If there are no activities that satisfy all of these conditions, a
25 6661     * null string is returned.
26 6662     *
27 6663     * <p>If multiple activities are found to satisfy the intent, the one with
28 6664     * the highest priority will be used.  If there are multiple activities
29 6665     * with the same priority, the system will either pick the best activity
30 6666     * based on user preference, or resolve to a system class that will allow
31 6667     * the user to pick an activity and forward from there.
32 6668     *
33 6669     * <p>This method is implemented simply by calling
34 6670     * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
35 6671     * true.</p>
36 6672     * <p> This API is called for you as part of starting an activity from an
37 6673     * intent.  You do not normally need to call it yourself.</p>
38 6674     *
39 6675     * @param pm The package manager with which to resolve the Intent.
40 6676     *
41 6677     * @return Name of the component implementing an activity that can
42 6678     *         display the intent.
43 6679     *
44 6680     * @see #setComponent
45 6681     * @see #getComponent
46 6682     * @see #resolveActivityInfo
47 6683     */
48 6684    public ComponentName resolveActivity(PackageManager pm) {
49 6685        if (mComponent != null) {
50 6686            return mComponent;
51 6687        }
52 6688
53 6689        ResolveInfo info = pm.resolveActivity(
54 6690            this, PackageManager.MATCH_DEFAULT_ONLY);
55 6691        if (info != null) {
56 6692            return new ComponentName(
57 6693                    info.activityInfo.applicationInfo.packageName,
58 6694                    info.activityInfo.name);
59 6695        }
60 6696
61 6697        return null;
62 6698    }

resolveActivityInfo經過pm獲取ActivityInfo

 1 6700    /**
 2 6701     * Resolve the Intent into an {@link ActivityInfo}
 3 6702     * describing the activity that should execute the intent.  Resolution
 4 6703     * follows the same rules as described for {@link #resolveActivity}, but
 5 6704     * you get back the completely information about the resolved activity
 6 6705     * instead of just its class name.
 7 6706     *
 8 6707     * @param pm The package manager with which to resolve the Intent.
 9 6708     * @param flags Addition information to retrieve as per
10 6709     * {@link PackageManager#getActivityInfo(ComponentName, int)
11 6710     * PackageManager.getActivityInfo()}.
12 6711     *
13 6712     * @return PackageManager.ActivityInfo
14 6713     *
15 6714     * @see #resolveActivity
16 6715     */
17 6716    public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
18 6717        ActivityInfo ai = null;
19 6718        if (mComponent != null) {
20 6719            try {
21 6720                ai = pm.getActivityInfo(mComponent, flags);
22 6721            } catch (PackageManager.NameNotFoundException e) {
23 6722                // ignore
24 6723            }
25 6724        } else {
26 6725            ResolveInfo info = pm.resolveActivity(
27 6726                this, PackageManager.MATCH_DEFAULT_ONLY | flags);
28 6727            if (info != null) {
29 6728                ai = info.activityInfo;
30 6729            }
31 6730        }
32 6731
33 6732        return ai;
34 6733    }

resolveSystemService經過pm的queryIntentService找到Intent匹配的servcie,若是有多個匹配,直接拋異常

 1 6735    /**
 2 6736     * Special function for use by the system to resolve service
 3 6737     * intents to system apps.  Throws an exception if there are
 4 6738     * multiple potential matches to the Intent.  Returns null if
 5 6739     * there are no matches.
 6 6740     * @hide
 7 6741     */
 8 6742    public ComponentName resolveSystemService(PackageManager pm, int flags) {
 9 6743        if (mComponent != null) {
10 6744            return mComponent;
11 6745        }
12 6746
13 6747        List<ResolveInfo> results = pm.queryIntentServices(this, flags);
14 6748        if (results == null) {
15 6749            return null;
16 6750        }
17 6751        ComponentName comp = null;
18 6752        for (int i=0; i<results.size(); i++) {
19 6753            ResolveInfo ri = results.get(i);
20 6754            if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
21 6755                continue;
22 6756            }
23 6757            ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
24 6758                    ri.serviceInfo.name);
25 6759            if (comp != null) {
26 6760                throw new IllegalStateException("Multiple system services handle " + this
27 6761                        + ": " + comp + ", " + foundComp);
28 6762            }
29 6763            comp = foundComp;
30 6764        }
31 6765        return comp;
32 6766    }
33 6767

setAction設置action,mAction是String.intern獲取常量池裏的引用這樣就不用動態構建了,加快處理速度

 1 6768    /**
 2 6769     * Set the general action to be performed.
 3 6770     *
 4 6771     * @param action An action name, such as ACTION_VIEW.  Application-specific
 5 6772     *               actions should be prefixed with the vendor's package name.
 6 6773     *
 7 6774     * @return Returns the same Intent object, for chaining multiple calls
 8 6775     * into a single statement.
 9 6776     *
10 6777     * @see #getAction
11 6778     */
12 6779    public Intent setAction(String action) {
13 6780        mAction = action != null ? action.intern() : null;
14 6781        return this;
15 6782    }

setData,setType一系列函數會在設置data或者type的時候清除另外一個,或者先將其轉換爲小寫

  1 6784    /**
  2 6785     * Set the data this intent is operating on.  This method automatically
  3 6786     * clears any type that was previously set by {@link #setType} or
  4 6787     * {@link #setTypeAndNormalize}.
  5 6788     *
  6 6789     * <p><em>Note: scheme matching in the Android framework is
  7 6790     * case-sensitive, unlike the formal RFC. As a result,
  8 6791     * you should always write your Uri with a lower case scheme,
  9 6792     * or use {@link Uri#normalizeScheme} or
 10 6793     * {@link #setDataAndNormalize}
 11 6794     * to ensure that the scheme is converted to lower case.</em>
 12 6795     *
 13 6796     * @param data The Uri of the data this intent is now targeting.
 14 6797     *
 15 6798     * @return Returns the same Intent object, for chaining multiple calls
 16 6799     * into a single statement.
 17 6800     *
 18 6801     * @see #getData
 19 6802     * @see #setDataAndNormalize
 20 6803     * @see android.net.Uri#normalizeScheme()
 21 6804     */
 22 6805    public Intent setData(Uri data) {
 23 6806        mData = data;
 24 6807        mType = null;
 25 6808        return this;
 26 6809    }
 27 6810
 28 6811    /**
 29 6812     * Normalize and set the data this intent is operating on.
 30 6813     *
 31 6814     * <p>This method automatically clears any type that was
 32 6815     * previously set (for example, by {@link #setType}).
 33 6816     *
 34 6817     * <p>The data Uri is normalized using
 35 6818     * {@link android.net.Uri#normalizeScheme} before it is set,
 36 6819     * so really this is just a convenience method for
 37 6820     * <pre>
 38 6821     * setData(data.normalize())
 39 6822     * </pre>
 40 6823     *
 41 6824     * @param data The Uri of the data this intent is now targeting.
 42 6825     *
 43 6826     * @return Returns the same Intent object, for chaining multiple calls
 44 6827     * into a single statement.
 45 6828     *
 46 6829     * @see #getData
 47 6830     * @see #setType
 48 6831     * @see android.net.Uri#normalizeScheme
 49 6832     */
 50 6833    public Intent setDataAndNormalize(Uri data) {
 51 6834        return setData(data.normalizeScheme());
 52 6835    }
 53 6836
 54 6837    /**
 55 6838     * Set an explicit MIME data type.
 56 6839     *
 57 6840     * <p>This is used to create intents that only specify a type and not data,
 58 6841     * for example to indicate the type of data to return.
 59 6842     *
 60 6843     * <p>This method automatically clears any data that was
 61 6844     * previously set (for example by {@link #setData}).
 62 6845     *
 63 6846     * <p><em>Note: MIME type matching in the Android framework is
 64 6847     * case-sensitive, unlike formal RFC MIME types.  As a result,
 65 6848     * you should always write your MIME types with lower case letters,
 66 6849     * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
 67 6850     * to ensure that it is converted to lower case.</em>
 68 6851     *
 69 6852     * @param type The MIME type of the data being handled by this intent.
 70 6853     *
 71 6854     * @return Returns the same Intent object, for chaining multiple calls
 72 6855     * into a single statement.
 73 6856     *
 74 6857     * @see #getType
 75 6858     * @see #setTypeAndNormalize
 76 6859     * @see #setDataAndType
 77 6860     * @see #normalizeMimeType
 78 6861     */
 79 6862    public Intent setType(String type) {
 80 6863        mData = null;
 81 6864        mType = type;
 82 6865        return this;
 83 6866    }
 84 6867
 85 6868    /**
 86 6869     * Normalize and set an explicit MIME data type.
 87 6870     *
 88 6871     * <p>This is used to create intents that only specify a type and not data,
 89 6872     * for example to indicate the type of data to return.
 90 6873     *
 91 6874     * <p>This method automatically clears any data that was
 92 6875     * previously set (for example by {@link #setData}).
 93 6876     *
 94 6877     * <p>The MIME type is normalized using
 95 6878     * {@link #normalizeMimeType} before it is set,
 96 6879     * so really this is just a convenience method for
 97 6880     * <pre>
 98 6881     * setType(Intent.normalizeMimeType(type))
 99 6882     * </pre>
100 6883     *
101 6884     * @param type The MIME type of the data being handled by this intent.
102 6885     *
103 6886     * @return Returns the same Intent object, for chaining multiple calls
104 6887     * into a single statement.
105 6888     *
106 6889     * @see #getType
107 6890     * @see #setData
108 6891     * @see #normalizeMimeType
109 6892     */
110 6893    public Intent setTypeAndNormalize(String type) {
111 6894        return setType(normalizeMimeType(type));
112 6895    }
113 6896
114 6897    /**
115 6898     * (Usually optional) Set the data for the intent along with an explicit
116 6899     * MIME data type.  This method should very rarely be used -- it allows you
117 6900     * to override the MIME type that would ordinarily be inferred from the
118 6901     * data with your own type given here.
119 6902     *
120 6903     * <p><em>Note: MIME type and Uri scheme matching in the
121 6904     * Android framework is case-sensitive, unlike the formal RFC definitions.
122 6905     * As a result, you should always write these elements with lower case letters,
123 6906     * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
124 6907     * {@link #setDataAndTypeAndNormalize}
125 6908     * to ensure that they are converted to lower case.</em>
126 6909     *
127 6910     * @param data The Uri of the data this intent is now targeting.
128 6911     * @param type The MIME type of the data being handled by this intent.
129 6912     *
130 6913     * @return Returns the same Intent object, for chaining multiple calls
131 6914     * into a single statement.
132 6915     *
133 6916     * @see #setType
134 6917     * @see #setData
135 6918     * @see #normalizeMimeType
136 6919     * @see android.net.Uri#normalizeScheme
137 6920     * @see #setDataAndTypeAndNormalize
138 6921     */
139 6922    public Intent setDataAndType(Uri data, String type) {
140 6923        mData = data;
141 6924        mType = type;
142 6925        return this;
143 6926    }
144 6927
145 6928    /**
146 6929     * (Usually optional) Normalize and set both the data Uri and an explicit
147 6930     * MIME data type.  This method should very rarely be used -- it allows you
148 6931     * to override the MIME type that would ordinarily be inferred from the
149 6932     * data with your own type given here.
150 6933     *
151 6934     * <p>The data Uri and the MIME type are normalize using
152 6935     * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
153 6936     * before they are set, so really this is just a convenience method for
154 6937     * <pre>
155 6938     * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
156 6939     * </pre>
157 6940     *
158 6941     * @param data The Uri of the data this intent is now targeting.
159 6942     * @param type The MIME type of the data being handled by this intent.
160 6943     *
161 6944     * @return Returns the same Intent object, for chaining multiple calls
162 6945     * into a single statement.
163 6946     *
164 6947     * @see #setType
165 6948     * @see #setData
166 6949     * @see #setDataAndType
167 6950     * @see #normalizeMimeType
168 6951     * @see android.net.Uri#normalizeScheme
169 6952     */
170 6953    public Intent setDataAndTypeAndNormalize(Uri data, String type) {
171 6954        return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
172 6955    }

addCategory和removeCategory增長和刪除Category

 1 6957    /**
 2 6958     * Add a new category to the intent.  Categories provide additional detail
 3 6959     * about the action the intent performs.  When resolving an intent, only
 4 6960     * activities that provide <em>all</em> of the requested categories will be
 5 6961     * used.
 6 6962     *
 7 6963     * @param category The desired category.  This can be either one of the
 8 6964     *               predefined Intent categories, or a custom category in your own
 9 6965     *               namespace.
10 6966     *
11 6967     * @return Returns the same Intent object, for chaining multiple calls
12 6968     * into a single statement.
13 6969     *
14 6970     * @see #hasCategory
15 6971     * @see #removeCategory
16 6972     */
17 6973    public Intent addCategory(String category) {
18 6974        if (mCategories == null) {
19 6975            mCategories = new ArraySet<String>();
20 6976        }
21 6977        mCategories.add(category.intern());
22 6978        return this;
23 6979    }
24 6980
25 6981    /**
26 6982     * Remove a category from an intent.
27 6983     *
28 6984     * @param category The category to remove.
29 6985     *
30 6986     * @see #addCategory
31 6987     */
32 6988    public void removeCategory(String category) {
33 6989        if (mCategories != null) {
34 6990            mCategories.remove(category);
35 6991            if (mCategories.size() == 0) {
36 6992                mCategories = null;
37 6993            }
38 6994        }
39 6995    }
40 6996

setSelector設置一個額外的Intent,決定哪一個組件處理它

 1 6997    /**
 2 6998     * Set a selector for this Intent.  This is a modification to the kinds of
 3 6999     * things the Intent will match.  If the selector is set, it will be used
 4 7000     * when trying to find entities that can handle the Intent, instead of the
 5 7001     * main contents of the Intent.  This allows you build an Intent containing
 6 7002     * a generic protocol while targeting it more specifically.
 7 7003     *
 8 7004     * <p>An example of where this may be used is with things like
 9 7005     * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
10 7006     * Intent that will launch the Browser application.  However, the correct
11 7007     * main entry point of an application is actually {@link #ACTION_MAIN}
12 7008     * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
13 7009     * used to specify the actual Activity to launch.  If you launch the browser
14 7010     * with something different, undesired behavior may happen if the user has
15 7011     * previously or later launches it the normal way, since they do not match.
16 7012     * Instead, you can build an Intent with the MAIN action (but no ComponentName
17 7013     * yet specified) and set a selector with {@link #ACTION_MAIN} and
18 7014     * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
19 7015     *
20 7016     * <p>Setting a selector does not impact the behavior of
21 7017     * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
22 7018     * desired behavior of a selector -- it does not impact the base meaning
23 7019     * of the Intent, just what kinds of things will be matched against it
24 7020     * when determining who can handle it.</p>
25 7021     *
26 7022     * <p>You can not use both a selector and {@link #setPackage(String)} on
27 7023     * the same base Intent.</p>
28 7024     *
29 7025     * @param selector The desired selector Intent; set to null to not use
30 7026     * a special selector.
31 7027     */
32 7028    public void setSelector(Intent selector) {
33 7029        if (selector == this) {
34 7030            throw new IllegalArgumentException(
35 7031                    "Intent being set as a selector of itself");
36 7032        }
37 7033        if (selector != null && mPackage != null) {
38 7034            throw new IllegalArgumentException(
39 7035                    "Can't set selector when package name is already set");
40 7036        }
41 7037        mSelector = selector;
42 7038    }

setClipData設置clipData

 1 7040    /**
 2 7041     * Set a {@link ClipData} associated with this Intent.  This replaces any
 3 7042     * previously set ClipData.
 4 7043     *
 5 7044     * <p>The ClipData in an intent is not used for Intent matching or other
 6 7045     * such operations.  Semantically it is like extras, used to transmit
 7 7046     * additional data with the Intent.  The main feature of using this over
 8 7047     * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
 9 7048     * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
10 7049     * items included in the clip data.  This is useful, in particular, if
11 7050     * you want to transmit an Intent containing multiple <code>content:</code>
12 7051     * URIs for which the recipient may not have global permission to access the
13 7052     * content provider.
14 7053     *
15 7054     * <p>If the ClipData contains items that are themselves Intents, any
16 7055     * grant flags in those Intents will be ignored.  Only the top-level flags
17 7056     * of the main Intent are respected, and will be applied to all Uri or
18 7057     * Intent items in the clip (or sub-items of the clip).
19 7058     *
20 7059     * <p>The MIME type, label, and icon in the ClipData object are not
21 7060     * directly used by Intent.  Applications should generally rely on the
22 7061     * MIME type of the Intent itself, not what it may find in the ClipData.
23 7062     * A common practice is to construct a ClipData for use with an Intent
24 7063     * with a MIME type of "*&#47;*".
25 7064     *
26 7065     * @param clip The new clip to set.  May be null to clear the current clip.
27 7066     */
28 7067    public void setClipData(ClipData clip) {
29 7068        mClipData = clip;
30 7069    }

prepareToLeaveUser切換userId

 1 7071    /**
 2 7072     * This is NOT a secure mechanism to identify the user who sent the intent.
 3 7073     * When the intent is sent to a different user, it is used to fix uris by adding the userId
 4 7074     * who sent the intent.
 5 7075     * @hide
 6 7076     */
 7 7077    public void prepareToLeaveUser(int userId) {
 8 7078        // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
 9 7079        // We want mContentUserHint to refer to the original user, so don't do anything.
10 7080        if (mContentUserHint == UserHandle.USER_CURRENT) {
11 7081            mContentUserHint = userId;
12 7082        }
13 7083    }

putExtra的重載函數,根據參數類型不一樣調用調用Bundle的不一樣函數放不一樣類型

  1 7085    /**
  2 7086     * Add extended data to the intent.  The name must include a package
  3 7087     * prefix, for example the app com.android.contacts would use names
  4 7088     * like "com.android.contacts.ShowAll".
  5 7089     *
  6 7090     * @param name The name of the extra data, with package prefix.
  7 7091     * @param value The boolean data value.
  8 7092     *
  9 7093     * @return Returns the same Intent object, for chaining multiple calls
 10 7094     * into a single statement.
 11 7095     *
 12 7096     * @see #putExtras
 13 7097     * @see #removeExtra
 14 7098     * @see #getBooleanExtra(String, boolean)
 15 7099     */
 16 7100    public Intent putExtra(String name, boolean value) {
 17 7101        if (mExtras == null) {
 18 7102            mExtras = new Bundle();
 19 7103        }
 20 7104        mExtras.putBoolean(name, value);
 21 7105        return this;
 22 7106    }
 23 7107
 24 7108    /**
 25 7109     * Add extended data to the intent.  The name must include a package
 26 7110     * prefix, for example the app com.android.contacts would use names
 27 7111     * like "com.android.contacts.ShowAll".
 28 7112     *
 29 7113     * @param name The name of the extra data, with package prefix.
 30 7114     * @param value The byte data value.
 31 7115     *
 32 7116     * @return Returns the same Intent object, for chaining multiple calls
 33 7117     * into a single statement.
 34 7118     *
 35 7119     * @see #putExtras
 36 7120     * @see #removeExtra
 37 7121     * @see #getByteExtra(String, byte)
 38 7122     */
 39 7123    public Intent putExtra(String name, byte value) {
 40 7124        if (mExtras == null) {
 41 7125            mExtras = new Bundle();
 42 7126        }
 43 7127        mExtras.putByte(name, value);
 44 7128        return this;
 45 7129    }
 46 7130
 47 7131    /**
 48 7132     * Add extended data to the intent.  The name must include a package
 49 7133     * prefix, for example the app com.android.contacts would use names
 50 7134     * like "com.android.contacts.ShowAll".
 51 7135     *
 52 7136     * @param name The name of the extra data, with package prefix.
 53 7137     * @param value The char data value.
 54 7138     *
 55 7139     * @return Returns the same Intent object, for chaining multiple calls
 56 7140     * into a single statement.
 57 7141     *
 58 7142     * @see #putExtras
 59 7143     * @see #removeExtra
 60 7144     * @see #getCharExtra(String, char)
 61 7145     */
 62 7146    public Intent putExtra(String name, char value) {
 63 7147        if (mExtras == null) {
 64 7148            mExtras = new Bundle();
 65 7149        }
 66 7150        mExtras.putChar(name, value);
 67 7151        return this;
 68 7152    }
 69 7153
 70 7154    /**
 71 7155     * Add extended data to the intent.  The name must include a package
 72 7156     * prefix, for example the app com.android.contacts would use names
 73 7157     * like "com.android.contacts.ShowAll".
 74 7158     *
 75 7159     * @param name The name of the extra data, with package prefix.
 76 7160     * @param value The short data value.
 77 7161     *
 78 7162     * @return Returns the same Intent object, for chaining multiple calls
 79 7163     * into a single statement.
 80 7164     *
 81 7165     * @see #putExtras
 82 7166     * @see #removeExtra
 83 7167     * @see #getShortExtra(String, short)
 84 7168     */
 85 7169    public Intent putExtra(String name, short value) {
 86 7170        if (mExtras == null) {
 87 7171            mExtras = new Bundle();
 88 7172        }
 89 7173        mExtras.putShort(name, value);
 90 7174        return this;
 91 7175    }
 92 7176
 93 7177    /**
 94 7178     * Add extended data to the intent.  The name must include a package
 95 7179     * prefix, for example the app com.android.contacts would use names
 96 7180     * like "com.android.contacts.ShowAll".
 97 7181     *
 98 7182     * @param name The name of the extra data, with package prefix.
 99 7183     * @param value The integer data value.
100 7184     *
101 7185     * @return Returns the same Intent object, for chaining multiple calls
102 7186     * into a single statement.
103 7187     *
104 7188     * @see #putExtras
105 7189     * @see #removeExtra
106 7190     * @see #getIntExtra(String, int)
107 7191     */
108 7192    public Intent putExtra(String name, int value) {
109 7193        if (mExtras == null) {
110 7194            mExtras = new Bundle();
111 7195        }
112 7196        mExtras.putInt(name, value);
113 7197        return this;
114 7198    }
115 7199
116 7200    /**
117 7201     * Add extended data to the intent.  The name must include a package
118 7202     * prefix, for example the app com.android.contacts would use names
119 7203     * like "com.android.contacts.ShowAll".
120 7204     *
121 7205     * @param name The name of the extra data, with package prefix.
122 7206     * @param value The long data value.
123 7207     *
124 7208     * @return Returns the same Intent object, for chaining multiple calls
125 7209     * into a single statement.
126 7210     *
127 7211     * @see #putExtras
128 7212     * @see #removeExtra
129 7213     * @see #getLongExtra(String, long)
130 7214     */
131 7215    public Intent putExtra(String name, long value) {
132 7216        if (mExtras == null) {
133 7217            mExtras = new Bundle();
134 7218        }
135 7219        mExtras.putLong(name, value);
136 7220        return this;
137 7221    }
138 7222
139 7223    /**
140 7224     * Add extended data to the intent.  The name must include a package
141 7225     * prefix, for example the app com.android.contacts would use names
142 7226     * like "com.android.contacts.ShowAll".
143 7227     *
144 7228     * @param name The name of the extra data, with package prefix.
145 7229     * @param value The float data value.
146 7230     *
147 7231     * @return Returns the same Intent object, for chaining multiple calls
148 7232     * into a single statement.
149 7233     *
150 7234     * @see #putExtras
151 7235     * @see #removeExtra
152 7236     * @see #getFloatExtra(String, float)
153 7237     */
154 7238    public Intent putExtra(String name, float value) {
155 7239        if (mExtras == null) {
156 7240            mExtras = new Bundle();
157 7241        }
158 7242        mExtras.putFloat(name, value);
159 7243        return this;
160 7244    }
161 7245
162 7246    /**
163 7247     * Add extended data to the intent.  The name must include a package
164 7248     * prefix, for example the app com.android.contacts would use names
165 7249     * like "com.android.contacts.ShowAll".
166 7250     *
167 7251     * @param name The name of the extra data, with package prefix.
168 7252     * @param value The double data value.
169 7253     *
170 7254     * @return Returns the same Intent object, for chaining multiple calls
171 7255     * into a single statement.
172 7256     *
173 7257     * @see #putExtras
174 7258     * @see #removeExtra
175 7259     * @see #getDoubleExtra(String, double)
176 7260     */
177 7261    public Intent putExtra(String name, double value) {
178 7262        if (mExtras == null) {
179 7263            mExtras = new Bundle();
180 7264        }
181 7265        mExtras.putDouble(name, value);
182 7266        return this;
183 7267    }
184 7268
185 7269    /**
186 7270     * Add extended data to the intent.  The name must include a package
187 7271     * prefix, for example the app com.android.contacts would use names
188 7272     * like "com.android.contacts.ShowAll".
189 7273     *
190 7274     * @param name The name of the extra data, with package prefix.
191 7275     * @param value The String data value.
192 7276     *
193 7277     * @return Returns the same Intent object, for chaining multiple calls
194 7278     * into a single statement.
195 7279     *
196 7280     * @see #putExtras
197 7281     * @see #removeExtra
198 7282     * @see #getStringExtra(String)
199 7283     */
200 7284    public Intent putExtra(String name, String value) {
201 7285        if (mExtras == null) {
202 7286            mExtras = new Bundle();
203 7287        }
204 7288        mExtras.putString(name, value);
205 7289        return this;
206 7290    }
207 7291
208 7292    /**
209 7293     * Add extended data to the intent.  The name must include a package
210 7294     * prefix, for example the app com.android.contacts would use names
211 7295     * like "com.android.contacts.ShowAll".
212 7296     *
213 7297     * @param name The name of the extra data, with package prefix.
214 7298     * @param value The CharSequence data value.
215 7299     *
216 7300     * @return Returns the same Intent object, for chaining multiple calls
217 7301     * into a single statement.
218 7302     *
219 7303     * @see #putExtras
220 7304     * @see #removeExtra
221 7305     * @see #getCharSequenceExtra(String)
222 7306     */
223 7307    public Intent putExtra(String name, CharSequence value) {
224 7308        if (mExtras == null) {
225 7309            mExtras = new Bundle();
226 7310        }
227 7311        mExtras.putCharSequence(name, value);
228 7312        return this;
229 7313    }
230 7314
231 7315    /**
232 7316     * Add extended data to the intent.  The name must include a package
233 7317     * prefix, for example the app com.android.contacts would use names
234 7318     * like "com.android.contacts.ShowAll".
235 7319     *
236 7320     * @param name The name of the extra data, with package prefix.
237 7321     * @param value The Parcelable data value.
238 7322     *
239 7323     * @return Returns the same Intent object, for chaining multiple calls
240 7324     * into a single statement.
241 7325     *
242 7326     * @see #putExtras
243 7327     * @see #removeExtra
244 7328     * @see #getParcelableExtra(String)
245 7329     */
246 7330    public Intent putExtra(String name, Parcelable value) {
247 7331        if (mExtras == null) {
248 7332            mExtras = new Bundle();
249 7333        }
250 7334        mExtras.putParcelable(name, value);
251 7335        return this;
252 7336    }
253 7337
254 7338    /**
255 7339     * Add extended data to the intent.  The name must include a package
256 7340     * prefix, for example the app com.android.contacts would use names
257 7341     * like "com.android.contacts.ShowAll".
258 7342     *
259 7343     * @param name The name of the extra data, with package prefix.
260 7344     * @param value The Parcelable[] data value.
261 7345     *
262 7346     * @return Returns the same Intent object, for chaining multiple calls
263 7347     * into a single statement.
264 7348     *
265 7349     * @see #putExtras
266 7350     * @see #removeExtra
267 7351     * @see #getParcelableArrayExtra(String)
268 7352     */
269 7353    public Intent putExtra(String name, Parcelable[] value) {
270 7354        if (mExtras == null) {
271 7355            mExtras = new Bundle();
272 7356        }
273 7357        mExtras.putParcelableArray(name, value);
274 7358        return this;
275 7359    }
276 7360
277 7361    /**
278 7362     * Add extended data to the intent.  The name must include a package
279 7363     * prefix, for example the app com.android.contacts would use names
280 7364     * like "com.android.contacts.ShowAll".
281 7365     *
282 7366     * @param name The name of the extra data, with package prefix.
283 7367     * @param value The ArrayList<Parcelable> data value.
284 7368     *
285 7369     * @return Returns the same Intent object, for chaining multiple calls
286 7370     * into a single statement.
287 7371     *
288 7372     * @see #putExtras
289 7373     * @see #removeExtra
290 7374     * @see #getParcelableArrayListExtra(String)
291 7375     */
292 7376    public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
293 7377        if (mExtras == null) {
294 7378            mExtras = new Bundle();
295 7379        }
296 7380        mExtras.putParcelableArrayList(name, value);
297 7381        return this;
298 7382    }
299 7383
300 7384    /**
301 7385     * Add extended data to the intent.  The name must include a package
302 7386     * prefix, for example the app com.android.contacts would use names
303 7387     * like "com.android.contacts.ShowAll".
304 7388     *
305 7389     * @param name The name of the extra data, with package prefix.
306 7390     * @param value The ArrayList<Integer> data value.
307 7391     *
308 7392     * @return Returns the same Intent object, for chaining multiple calls
309 7393     * into a single statement.
310 7394     *
311 7395     * @see #putExtras
312 7396     * @see #removeExtra
313 7397     * @see #getIntegerArrayListExtra(String)
314 7398     */
315 7399    public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
316 7400        if (mExtras == null) {
317 7401            mExtras = new Bundle();
318 7402        }
319 7403        mExtras.putIntegerArrayList(name, value);
320 7404        return this;
321 7405    }
322 7406
323 7407    /**
324 7408     * Add extended data to the intent.  The name must include a package
325 7409     * prefix, for example the app com.android.contacts would use names
326 7410     * like "com.android.contacts.ShowAll".
327 7411     *
328 7412     * @param name The name of the extra data, with package prefix.
329 7413     * @param value The ArrayList<String> data value.
330 7414     *
331 7415     * @return Returns the same Intent object, for chaining multiple calls
332 7416     * into a single statement.
333 7417     *
334 7418     * @see #putExtras
335 7419     * @see #removeExtra
336 7420     * @see #getStringArrayListExtra(String)
337 7421     */
338 7422    public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
339 7423        if (mExtras == null) {
340 7424            mExtras = new Bundle();
341 7425        }
342 7426        mExtras.putStringArrayList(name, value);
343 7427        return this;
344 7428    }
345 7429
346 7430    /**
347 7431     * Add extended data to the intent.  The name must include a package
348 7432     * prefix, for example the app com.android.contacts would use names
349 7433     * like "com.android.contacts.ShowAll".
350 7434     *
351 7435     * @param name The name of the extra data, with package prefix.
352 7436     * @param value The ArrayList<CharSequence> data value.
353 7437     *
354 7438     * @return Returns the same Intent object, for chaining multiple calls
355 
相關文章
相關標籤/搜索