代码位于frameworks/base/core/java/anroid/Content/Intent.java
Intent是对要进行操作的一种抽象描述。用action抽象操作,用data(android.net.Uri)抽象操作参数。
除此之外,category用来描述action所属的类别(添加action对应的component的额外属性)来指导系相应的component如何被匹配与被处理,type用来指定data的MIME类型;component指定用来执行action的组件,如果指定了这个,其他参数被忽略;extra用来给component相应方法附加额外的所需参数。
先打成package android.content,并import这些类
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接口
1 619public class Intent implements Parcelable, Cloneable {
定义了的attr字符串有action,category,type,component,data,flags
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,extra
1 621 private static final String TAG_CATEGORIES = "categories"; 2 623 private static final String TAG_EXTRA = "extra";
时间: 2024-10-13 01:59:30