Activity details Intent explicit jump and implicit jump

Source: Internet
Author: User

Activity Life Cycle explicit Intent call 1 // create an explicit Intent object (Method 1: specified in the constructor) 2 Intent intent Intent = new Intent (Intent_Demo1.this, Intent_Demo1_Result1.class ); 3 4 Bundle bundle = new Bundle (); 5 bundle. putString ("id", strID); 6 intent. putExtras (bundle); 7 8 intent. putExtra ("name", "bbb"); 9 intent. putExtra ("userInfo", new UserInfo (1, "name"); 10 startActivity (intent); 11 12 // create an explicit Intent object (Method 2: use the setClass method) 13 Int Ent intent = new Intent (); 14 Bundle bundle = new Bundle (); 15 bundle. putString ("id", strID); 16 intent. setClass (Intent_Demo1.this, Intent_Demo1_Result1.class); 17 intent. putExtras (bundle); 18 startActivity (intent); 19 20 // create an explicit Intent object (method 3: Use the setClass method) 21 Intent intent = new Intent (); 22 Bundle bundle = new Bundle (); 23 bundle. putString ("id", strID); 24 intent. setClassName (Intent_Demo1.this, "com. gr Eat. activity_intent.intent_demow.result1 "); 25 intent. putExtras (bundle); 26 startActivity (intent); 27 28 // create an explicit Intent object (Method 4: Use the setComponent method) 29 Intent intent = new Intent (); 30 Bundle bundle = new Bundle (); 31 bundle. putString ("id", strID); 32 // parameter of the setComponent method: ComponentName33 intent. setComponent (new ComponentName (Intent_Demo1.this, Intent_Demo1_Result1.class); 34 intent. putExtras (bundle); 35 sta RtActivity (intent); Intent implicitly redirects to Action 1 // create an implicit Intent object: Action 2/*** here AndroidManifest is specified. <action android: name = "com. great. activity_intent.intent_demow.result3 "/> 5 *. Note that you must set <category android: name =" android. intent. category. DEFAULT "/> 6 */7 Intent intent = new Intent (); 8 // set Intent action 9 intent. setAction ("com. great. activity_intent.Int Ent_demow.result3 "); 10 Bundle bundle = new Bundle (); 11 bundle. putString ("id", strID); 12 intent. putExtras (bundle); 13 startActivity (intent); AndroidManifest. xml 1 <activity android: name = "intent_demow.result3" 2 android: label = "intent_demow.result3"> 3 <intent-filter> 4 <action android: name = "com. great. activity_intent.intent_demow.result3 "/> 5 <category android: name =" android. intent. category. DEFAULT "/> 6 </Intent-filter> 7 </activity> Category 1 // create an implicit Intent object: Category 2 Intent intent = new Intent (); 3 intent. setAction ("com. great. activity_intent.intent_demow.result33 "); 4/** 5 * does not specify Category or only AndroidManifest. any Category 6 * <category android: name = "android. intent. category. except for DEFAULT "/>, you can access the Activity, which is 7 */8 intent. addCategory (Intent. CATEGORY_INFO ); 9 intent. addCategory (Intent. CATEGORY_DEFAULT); 10 Bundle bundle = new Bundle (); 11 bundle. putString ("id", strID); 12 intent. putExtras (bundle); 13 startActivity (intent); AndroidManifest. xml <activity android: name = "intent_demow.result2" android: label = "intent_demow.result2"> <intent-filter> <category android: name = "android. intent. category. INFO "/> <category android: name =" android. intent. category. BROWSABLE" /> <Category android: name = "android. intent. category. DEFAULT "/> </intent-filter> </activity> Date data jump 1 // create an implicit Intent object. Method 4: date data 2 Intent intent = new Intent (); 3 Uri uri = Uri. parse ("http://www.great.org: 8080/folder/subfolder/etc/abc.pdf"); 4 5 // Note: setData, setDataAndType, setType can only be used separately, you cannot share 6 // or set URI 7 using the setData method. // intent. setData (uri); 8 // either set the URI and mime separately using the setDataAndType Method Type 9 intent. setDataAndType (uri, "text/plain"); 10 // either set Type11 // intent separately using the setDataAndType method. setType ("text/plain"); 12 13/** 14 * do not specify Category or only specify AndroidManifest. any Category15 * <category android: name = "android. intent. category. except for DEFAULT "/>, you can access the Activity16 */17 Bundle bundle = new Bundle (); 18 bundle. putString ("id", strID); 19 intent. putExtras (bundle); 20 startAc Tibench (intent); AndroidManifest. xml 1 <activity android: name = "intent_demow.result2" 2 android: label = "intent_demow.result2"> 3 <intent-filter> 4 <category android: name = "android. intent. category. DEFAULT "/> 5 <data 6 android: scheme =" http "7 android: host =" www.great.org "8 android: port =" 8080 "9 android: pathPattern = ". * pdf "10 android: mimeType =" text/plain "/> 11 </intent-filter> 12 </activity> 13 call system components/w Eb browser Uri uri = Uri. parse ("http://www.baidu.com: 8080/image/a.jpg"); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // map (to be tested on the Android phone) Uri uri = Uri. parse ("geo: 38.899533,-77.036476"); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // URL planning Uri uri = Uri. parse ("http://maps.google.com/maps? F = d & saddr = startLat % 20 startLng & daddr = endLat % 20 endLng & hl = en "); Intent it = new Intent (Intent. ACTION_VIEW, uri); startActivity (it); // call the dialing program Uri = uri. parse ("tel: 15980665805"); Intent intent = new Intent (Intent. ACTION_DIAL, uri); startActivity (intent); // call-call directly. // to use this function, you must add <uses-permission android: name = "android. permission. CALL_PHONE "/> Uri uri = Uri. parse ("tel: 15980665805"); Intent Intent = new Intent (Intent. ACTION_CALL, uri); startActivity (intent); // call the SMS sending program (method 1) Uri uri = Uri. parse ("Maid: 15980665805"); Intent intent = new Intent (Intent. ACTION_SENDTO, uri); intent. putExtra ("sms_body", "The SMS text"); startActivity (intent); // call The SMS sending program (method 2) Intent intent = new Intent (Intent. ACTION_VIEW); intent. putExtra ("sms_body", "The SMS text"); intent. setType ("vnd. android-dir/mms-sms "); StartActivity (intent); // send MMS Uri uri = Uri. parse ("content: // media/external/images/media/23"); Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra ("sms_body", "some text"); intent. putExtra (Intent. EXTRA_STREAM, uri); intent. setType ("image/png"); startActivity (intent); // send Email (method 1) (test only on Android phone) Uri uri Uri = Uri. parse ("mailto: zhangsan@gmail.com"); Intent intent = new Intent (Intent. ACTION_SENDTO, uri); startActivity (intent); // send Email (method 2) (test only on Android mobile phone) Intent intent = new Intent (Intent. ACTION_SENDTO); intent. setData (Uri. parse ("mailto: zhangsan@gmail.com"); intent. putExtra (Intent. EXTRA_SUBJECT, "this is the title"); intent. putExtra (Intent. EXTRA_TEXT, "this is the content"); startActivity (intent); // send Email (method 3) (test only on Android phone) Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra (I Ntent. EXTRA_EMAIL, "me@abc.com"); intent. putExtra (Intent. EXTRA_SUBJECT, "this is the title"); intent. putExtra (Intent. EXTRA_TEXT, "this is the content"); intent. setType ("text/plain"); // select an email client startActivity (Intent. createChooser (intent, "Choose Email Client"); // send an Email (Method 4) (test only on Android phones) Intent intent = new Intent (Intent. ACTION_SEND); // recipient String [] tos = {"to1@abc.com", "to2@abc.com"}; // CC to String [] ccs = {"C0 @ AB C.com "," cc2@abc.com "}; // bcc String [] bcc = {" bcc1@abc.com "," bcc2@abc.com "}; intent. putExtra (Intent. EXTRA_EMAIL, tos); intent. putExtra (Intent. EXTRA_CC, ccs); intent. putExtra (Intent. EXTRA_BCC, bcc); intent. putExtra (Intent. EXTRA_SUBJECT, "this is the title"); intent. putExtra (Intent. EXTRA_TEXT, "this is the content"); intent. setType ("message/rfc822"); startActivity (Intent. createChooser (intent, "Choose Email Client"); // send Ema Il and send the attachment (to be tested on the Android phone) Intent intent = new Intent (Intent. ACTION_SEND); intent. putExtra (Intent. EXTRA_SUBJECT, "The email subject text"); intent. putExtra (Intent. EXTRA_STREAM, "file: // sdcard/mp3/intoxicating"); intent. setType ("audio/mp3"); startActivity (Intent. createChooser (intent, "Choose Email Client"); // play media files (android does not support files with Chinese names) Intent intent = new Intent (Intent. ACTION_VIEW); // Uri uri = Uri. Parse ("file: // sdcard/zhybriddb"); Uri uri = Uri. parse ("file: // sdcard/a.mp3"); intent. setDataAndType (uri, "audio/mp3"); startActivity (intent); Uri uri = Uri. withAppendedPath (MediaStore. audio. media. INTERNAL_CONTENT_URI, "1"); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); // music selector // It uses Intent. ACTION_GET_CONTENT and MIME types are used to search for all Data pickers that support audio/*. You can select one of the Intent int types. Ent = new Intent (Intent. ACTION_GET_CONTENT); intent. setType ("audio/*"); // Intent. createChooser: Application selector. This method creates an ACTION_CHOOSER Intent startActivity (Intent. createChooser (intent, "Select music"); Intent intent1 = new Intent (Intent. ACTION_GET_CONTENT); intent1.setType ("audio/*"); Intent intent2 = new Intent (Intent. ACTION_CHOOSER); intent2.putExtra (Intent. EXTRA_INTENT, intent1); intent2.putExtra (Intent. EXTRA_T ITLE, "aaaa"); startActivity (intent2); // set wallpaper // Intent intent = new Intent (Intent. ACTION_SET_WALLPAPER); // startActivity (Intent. createChooser (intent, "set Wallpaper"); // uninstall APK // fromParts method // parameter 1: URI's scheme // parameter 2: Package path // parameter 3: uri uri = Uri. fromParts ("package", "com. great. activity_intent ", null); Intent intent = new Intent (Intent. ACTION_DELETE, uri); startActivity (intent); // install APK (???) Uri uri = Uri. fromParts ("package", "com. great. activity_intent ", null); Intent intent = new Intent (Intent. ACTION_PACKAGE_ADDED, uri); startActivity (intent); // call Search Intent intent = new Intent (); intent. setAction (Intent. ACTION_WEB_SEARCH); intent. putExtra (SearchManager. QUERY, "android"); startActivity (intent );

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.