Three components of the Android application--activities, Services, broadcast Receiver, triggered by the message, the message is intent, Chinese translation to "intention" (I feel that reading is not smooth, or read English). We are able to launch three components through intent and carry data through intent to other components. This article looks at how to use the intent boot component, as well as the intent filtering rules.
Intent Object
First, look at the members included in the intent object.
private String maction; Action Private Uri Mdata; Data private string Mtype;private string mpackage; Package name private ComponentName mcomponent; The component name includes the package name + class name, and the application package name private int mflags; Logo private hashset<string> mcategories; Kind of private Bundle mextras; Additional Information private Rect msourcebounds;private Intent mselector;private clipdata mclipdata;
See intent source code, mainly including the above members.
Intent parsing
There are two ways of intent parsing: explicit parsing and implicit parsing.
Explicit parsing. We pass the components directly into the. Opening this specified component is simpler and usually used within the application.
For example, we create an explicit intent:
Intent intent = new Intent(context, OtherActivity.class);
Implicit parsing, no detailed components are specified, and the components are matched by rules. Often used by multiple programs to call each other much more. We use an implicit parsing. Action, data (including URI and datatype), category must have. For example, if we launch a browser to open a URL, intent can create:
Intent intent = new Intent(Intent.ACTION_VIEW);intent.setData(Uri.parse("http://blog.isming.me"));
The above does not fill the category, the creation of intent will be voluntarily filled out as default.
Wait for a refill. Nonsense
Well, it would have been like. Will write very long, but really want to write, when it is so simple to find. There's nothing to write about. Look at the source code more next time. And see if there's anything to add. It's Jiangzi!
Original address: http://blog.isming.me/blog/2014/06/15/use-intent-start-component/. Welcome reprint, Reproduced please indicate the source.
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
To start a component using intent