<span id="Label3"></p><p><br>Intent Intent<br><br><br>I. Explicit intent<br>Directly specify the class to Implement:<br>Intent intent=new Intent (mainactivity.this,xxx.class);<br>This.startactivity (intent);<br><br>Ii. Implicit Intent<br>1:xml Configuration: Adds an attribute <intent-filter></intent-filter> to the configuration of the class to which the intent is directed, such as:<br><activity<br>Android:name= "com.example.activity.twoActivity"<br>Android:label= "the other"<br><intent-filter><br><action android:name= "com.xxx.xxxx"/><br><data android:mimetype= "text/string"/><br><category android:name= "android.intent.category.DEFAULT"/><br></intent-filter><br>Android:launchmode= "singleinstance"/><br><br>2: use in form activity:<br>Intent Intent =new Intent ();<br>Intent.setaction ("com.xxxx.xxxx");<br>Intent.settype ("text/string");<br>Intent.addcategory (Intent.CATEGORY.DEFAULT);<br>This.startactivity (intent)<br><br>Note: in implicit intent, multiple actions/classes can be used at the same time, and will be automatically selected for the user at Startup.<br><br><br>Four components: Activity, contentprovider, broadcastreceive, Service<br><br> <br>first, Activity Form<br><br>1. Life cycle<br>1.onCreate () is called when the form is created<br>2.onStart () called when the form interface is visible<br>3.onResume () Called when the user gets focus<br>4.onPause () is called when it loses focus<br>5.onStop () is called when the form interface is not visible<br>6.onDestory () is called when the form is destroyed<br>7.onRestart Restart Form<br>Open form:<br>Minimized: 4-5<br>Recover form Size: 7-2-3<br>Close Form: 4-5-6<br><br>2. Screen switching<br><activity android:configchanges= "orentagion|keyboardhidden|screensize"--window change does not reset<br>android:screenorentation= "landscape"---set the window orientation, default Auto-sensing. Landscape: Landscape.<br><br>3. Activation mode of activity<br><activity launchmode= ""<br>Standard: default mode<br>Singletop: If the activity is at the top, the system will not be Recreated. instead, the Onnewintent method of the current activity is Called.<br>Singletask: keep the task stack with only one activity, if the activity you want to start already exists, it will reuse existing activity and clear all the windows on the Activity.<br>Singinstance: There is only one activity in the entire System. it runs on a self-contained task stack, and only one instance of the task stack exists<br><br>Ii. ContentProvider content providers<br><br>third, Broadcastreceiver Broadcast Recipients<br><br>1, the orderly broadcast ———— all can accept, can not be modified can not be intercepted.<br>1. Send the broadcast<br>public void Sendbroadcast (view View) {<br>Intent Intent =new Intent ();<br>Intent.setaction ("com.xxx.xxxx");<br>This.sendbroadcast (intent);<br>}<br><br>2. Receiving broadcasts<br>Configuration file:<br><activity><br></activity><br><receiver android:name= "com.xxxx.xxxxx" >--broadcast Name<br><intent-filter><br><action android:name= "xxxxxx"/>--detection Object name<br></intent-filter><br></receiver><br><br>Broadcast. Java files:<br>Inherit Broadcastreceiver<br><br>Data and modifications can be obtained (not referring to broadcast Content)<br>For Example: Call<br>This.getresultdata (); Get the Caller's outgoing call<br>This.setresultdata ("xxx"); Modify the Caller's outgoing call<br><br>2, Disorderly Broadcasting —————— a first-level downward transmission, can be modified to intercept broadcast Content.<br>1. Orderly broadcast<br>Intent Intent =new Intent ();<br>Intent.setaction ("com.xxx.xxxx");<br>This.sendorderedbroadcast (intent,recriverpermission,resultreceiver,scheduler,initialcode,initialdata, initialextras);<br>Such as: this.sendorderedbroadcast (intent,null,null,null, "400", "broadcast content", null);<br><br>2. Receive ordered broadcasts<br>Configuration file:<br><activity><br></activity><br><receiver android:name= "com.xxxx.xxxxx3" >--broadcast Name<br><intent-filter android:priority= "" ">----representative level, The first to receive a large number<br><action android:name= "xxxxxx"/>--detection Object name<br></intent-filter><br></receiver><br><receiver android:name= "com.xxxx.xxxxx2" >--broadcast Name<br><intent-filter android:priority= ">"<br><action android:name= "xxxxxx"/>--detection Object name<br></intent-filter><br></receiver><br><br>Broadcast. Java files:<br>Inherit Broadcastreceiver<br>This.getresultdata (); Get broadcast Content<br>This.setresultdata ("xxx"); Modify broadcast Content<br>This.abortbroadcast (); Intercept Stop broadcast<br><br><br>Iv. Service Services<br>------a component (class) running in the background<br><br>1. Priority levels for processes and processes<br>The process ———— an Application.<br>Priority: High-to-low<br>1.Foreground process that the foreground process user is using<br>2.visible process visible processes can be seen by processes (E.G. floating Windows)<br>3.service Process Service process with background service<br>4.background process background process minimized but not closed<br>5.Empty process does not have any activity (the return key has been returned to the DESKTOP)<br><br>2. Service life cycle<br>OnCreate () is called when it is created<br>Called when Onstartcommand () is enabled<br>Ondestory () is called when it is destroyed<br><br>3. Use<br>1. Create<br>New Java Inheritance Service<br>Configuration file:<br><service android:name= "com.xxx.xxx" ></service><br>2. use<br>Enabled: (if The service does not exist, create a service and then turn it On)<br>Intent intent=new Intent (mainactivity.this,xxxx.cladss);<br>This.startservice (intent);<br>Shut down:<br>Intent intent=new Intent (mainactivity.this,xxxx.class);<br>This.stopservice (intent);</p><p><p>Android Intent and four components</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service