Android built-in applications

Source: Internet
Author: User

Android built-in applications

Intent jump to the dial-up interface, contact interface, text message interface, and other functions in the system application need to jump directly to the dial-up, contact, text message interface, and so on, find a lot of information, and tidy up it yourself. First, let's look at the dialing interface first. The Code is as follows: Intent intent = new Intent (); intent. setAction ("android. intent. action. CALL_BUTTON "); startActivity (intent); and Uri uri = Uri. parse ("tel: xxxxxx"); Intent intent = new Intent (Intent. ACTION_DIAL, uri); startActivity (intent); both of them are supported. However, if you want to jump to the application, run the following code: Intent intent = new Intent ("android. intent. action. DIAL "); intent. setClassName ("com. android. contacts "," com. android. contacts. dialtactsActivity "); go to the call history page: Intent intent = new Intent (); intent. setAction (Intent. ACTION_CALL_BUTTON); startActivity (intent); to the Contact Interface: Intent intent = new Intent (); intent. setAction (Intent. ACTION_VIEW); intent. setData (Contacts. people. CONTENT_URI); startActivity (intent); similarly, to the Application: Intent intent = new Intent ("com. android. contacts. action. LIST_STREQUENT "); intent. setClassName ("com. android. contacts "," com. android. contacts. dialtactsActivity "); call Contact Interface: Intent intent = new Intent (); intent. setAction (Intent. ACTION_PICK); intent. setData (Contacts. people. CONTENT_URI); startActivity (intent); insert the contact Intent intent = new Intent (Intent. ACTION_EDIT, Uri. parse ("content: // com. android. contacts/"+" 1 "); startActivity (intent); Intent intent = new Intent (Intent. ACTION_INSERT_OR_EDIT); intent. setType ("vnd. android. cursor. item/person "); intent. setTyp E ("vnd. android. cursor. item/contact "); intent. setType ("vnd. android. cursor. item/raw_contact "); intent. putExtra (android. provider. contactsContract. intents. insert. NAME, name); intent. putExtra (android. provider. contactsContract. intents. insert. COMPANY, company); intent. putExtra (android. provider. contactsContract. intents. insert. PHONE, tel); intent. putExtra (android. provider. contactsContract. intents. insert. PHO NE_TYPE, 3); to the text message interface: Intent intent = new Intent (Intent. ACTION_VIEW); intent. setType ("vnd. android-dir/mms-sms "); // intent. setData (Uri. parse ("content: // mms-sms/conversations/"); // This is the number startActivity (intent); to the application: Intent intent = new Intent ("android. intent. action. CONVERSATION "); startActivity (intent); The following are other methods found online: 1. search for Intent intent = new Intent (); intent from google. setAction (Intent. ACTION_WEB_SEARCH); intent. PutExtra (SearchManager. QUERY, "searchString") startActivity (intent); 2. browse webpage Uri uri = Uri. parse ("http://www.google.com"); Intent it = new Intent (Intent. ACTION_VIEW, uri); startActivity (it); 3. show map Uri uri = Uri. parse ("geo: 38.899533,-77.036476"); Intent it = new Intent (Intent. action_VIEW, uri); startActivity (it); 4. path Planning Uri uri = Uri. parse ("http://maps.google.com/maps? F = dsaddr = startLat % 20 startLng & daddr = endLat % 20 endLng & hl = en "); Intent it = new Intent (Intent. ACTION_VIEW, URI); startActivity (it); 5. call Uri uri = Uri. parse ("tel: xxxxxx"); Intent it = new Intent (Intent. ACTION_DIAL, uri); startActivity (it); and uri = Uri. parse ("tel:" + number); intent = new Intent (Intent. ACTION_CALL, uri); startActivity (intent); you can test it by yourself. 6. intent it = new Intent (Intent. ACTION_VIEW); it. putExtra ("sms_body", "The SMS text"); it. setType ("vnd. android-dir/mms-sms "); startActivity (it); and uri = Uri. parse ("smsto:" + number of the recipient of the message to be sent); intent = new Intent (Intent. ACTION_SENDTO, uri); startActivity (intent); and mIntent = new Intent (Intent. ACTION_VIEW); mIntent. putExtra ("address", c. getString (c. getColumnIndex (column); mIntent. setType ("vnd. androi D-dir/mms-sms "); startActivity (mIntent); 7. send SMS Uri uri = Uri. parse ("Maid: 0800000123"); Intent it = new Intent (Intent. ACTION_SENDTO, uri); it. putExtra ("sms_body", "The SMS text"); startActivity (it); String body = "this is sms demo"; Intent mmsintent = new Intent (Intent. ACTION_SENDTO, Uri. fromParts ("smsto", number, null); mmsintent. putExtra (Messaging. KEY_ACTION_SENDTO_MESSAGE_BODY, body); mmsintent. putExtr A (Messaging. KEY_ACTION_SENDTO_COMPOSE_MODE, true); mmsintent. putExtra (Messaging. KEY_ACTION_SENDTO_EXIT_ON_SENT, true); startActivity (mmsintent); 8. send MMS Uri uri = Uri. parse ("content: // media/external/images/media/23"); Intent it = new Intent (Intent. ACTION_SEND); it. putExtra ("sms_body", "some text"); it. putExtra (Intent. EXTRA_STREAM, uri); it. setType ("image/png"); startActivity (it); StringBuilder sb = new Strin GBuilder (); sb. append ("file: //"); sb. append (fd. getAbsoluteFile (); Intent intent = new Intent (Intent. ACTION_SENDTO, Uri. fromParts ("mmsto", number, null); // Below extra datas are all optional. intent. putExtra (Messaging. KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject); intent. putExtra (Messaging. KEY_ACTION_SENDTO_MESSAGE_BODY, body); intent. putExtra (Messaging. KEY_ACTION_SENDTO_CONTENT_URI, sb. toString (); inten T. putExtra (Messaging. KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode); intent. putExtra (Messaging. KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent); startActivity (intent); 9. send EmailUri uri = Uri. parse ("mailto: xxx@abc.com"); Intent it = new Intent (Intent. ACTION_SENDTO, uri); startActivity (it); Intent it = new Intent (Intent. ACTION_SEND); it. putExtra (Intent. EXTRA_EMAIL, "me@abc.com"); it. putExtra (Intent. EXTRA_TEXT, "T He email body text "); it. setType ("text/plain"); startActivity (Intent. createChooser (it, "Choose Email Client"); Intent it = new Intent (Intent. ACTION_SEND); String [] tos = {"me@abc.com"}; String [] ccs = {"you@abc.com"}; it. putExtra (Intent. EXTRA_EMAIL, tos); it. putExtra (Intent. EXTRA_CC, ccs); it. putExtra (Intent. EXTRA_TEXT, "The email body text"); it. putExtra (Intent. EXTRA_SUBJECT, "The email subject text"); it. setTy Pe ("message/rfc822"); startActivity (Intent. createChooser (it, "Choose Email Client"); Intent it = new Intent (Intent. ACTION_SEND); it. putExtra (Intent. EXTRA_SUBJECT, "The email subject text"); it. putExtra (Intent. EXTRA_STREAM, "file: // sdcard/mysong.mp3"); sendIntent. setType ("audio/mp3"); startActivity (Intent. createChooser (it, "Choose Email Client"); 10. play multimedia Intent it = new Intent (Intent. ACTION_VIEW); Ur I uri = Uri. parse ("file: // sdcard/song.mp3"); it. setDataAndType (uri, "audio/mp3"); startActivity (it); Uri uri = Uri. withAppendedPath (MediaStore. audio. media. INTERNAL_CONTENT_URI, "1"); Intent it = new Intent (Intent. ACTION_VIEW, uri); startActivity (it); 11. uninstall apkUri uri = Uri. fromParts ("package", strPackageName, null); Intent it = new Intent (Intent. ACTION_DELETE, uri); startActivity (it); 12. install ApkUri installUri = Uri. fromParts ("package", "xxx", null); returnIt = new Intent (Intent. ACTION_PACKAGE_ADDED, installUri); 13. enable camera <1> Intent I = new Intent (Intent. ACTION_CAMERA_BUTTON, null); this. sendBroadcast (I); <2> long dateTaken = System. currentTimeMillis (); String name = createName (dateTaken) + ". jpg "; fileName = folder + name; ContentValues values = new ContentValues (); values. put (Images. medi A. TITLE, fileName); values. put ("_ data", fileName); values. put (Images. media. PICASA_ID, fileName); values. put (Images. media. DISPLAY_NAME, fileName); values. put (Images. media. DESCRIPTION, fileName); values. put (Images. imageColumns. BUCKET_DISPLAY_NAME, fileName); Uri photoUri = getContentResolver (). insert (MediaStore. images. media. EXTERNAL_CONTENT_URI, values); Intent inttPhoto = new Intent (MediaStore. ACT ION_IMAGE_CAPTURE); inttPhoto. putExtra (MediaStore. EXTRA_OUTPUT, photoUri); startActivityForResult (inttPhoto, 10); 14. select image Intent I = new Intent (); I. setType ("image/*"); I. setAction (Intent. ACTION_GET_CONTENT); startActivityForResult (I, 11); 15. enable the recorder Intent mi = new Intent (Media. RECORD_SOUND_ACTION); startActivity (mi); 16. displays the application detail list Uri uri = Uri. parse ("market: // details? Id = app_id "); Intent it = new Intent (Intent. ACTION_VIEW, uri); startActivity (it); // where app_id is the application ID, find the ID // by clicking on your application on Market home // page, and notice the ID from the address bar was not found in the app id just now, it was found that the package name can also be Uri uri = Uri. parse ("market: // details? Id = <packagename> "); in this example, we simply search for the Application Uri uri = Uri. parse (" market: // search? Q = pname: pkg_name "); Intent it = new Intent (Intent. ACTION_VIEW, uri); startActivity (it); // where pkg_name is the full package path for an application18 open the contact list <1> Intent I = new Intent (); I. setAction (Intent. ACTION_GET_CONTENT); I. setType ("vnd. android. cursor. item/phone "); startActivityForResult (I, REQUEST_TEXT); <2> Uri uri = Uri. parse ("content: // contacts/people"); Intent it = new Intent (Intent. ACTION_PICK, ur I); startActivityForResult (it, REQUEST_TEXT); 19 open another program Intent I = new Intent (); ComponentName cn = new ComponentName ("com. yellowbook. android2 "," com. yellowbook. android2.AndroidSearch "); I. setComponent (cn); I. setAction ("android. intent. action. MAIN "); startActivityForResult (I, RESULT_ OK); 20 Add to SMS inbox ContentValues cv = new ContentValues (); cv. put ("type", "1"); cv. put ("address", "SMS address"); cv. put ("body", "text message content"); g EtContentResolver (). insert (Uri. parse ("content: // sms/inbox"), cv); 21 query Cursor cursor from the SIM card or contact; Uri uri Uri; if (type = 1) {Intent intent = new Intent (); intent. setData (Uri. parse ("content: // icc/adn"); uri = intent. getData ();} else uri = People. CONTENT_URI; cursor = activity. getContentResolver (). query (uri, null, null); while (cursor. moveToNext () {int peopleId = cursor. getColumnIndex (Peop Le. _ ID); int nameId = cursor. getColumnIndex (People. NAME); int phoneId = cursor. getColumnIndex (People. NUMBER);} view a contact. Of course, this is ACTION_VIEW. If you select and return the action to ACTION_PICK, startActivityforResultUri personUri = ContentUris is required for intent processing. withAppendedId (People. CONTENT_URI, ID); // The last ID parameter is the database BaseID in the contact Provider, that is, the row of Intent intent = new Intent (); intent. setAction (Intent. ACTION_VIEW); intent. setData (personUri ); StartActivity (intent); 22 Delete uri = ContentUris. withAppendedId (People. CONTENT_URI, contact id); int count = activity. getContentResolver (). delete (uri, null, null); 23 add to contact: ContentValues cv = new ContentValues (); ArrayList <ContentProviderOperation> operationList = new ArrayList <ContentProviderOperation> (); ContentProviderOperation. builder builder = ContentProviderOperation. newInsert (RawContacts. CONTENT_U RI); builder. withValues (cv); operationList. add (builder. build (); builder = ContentProviderOperation. newInsert (Data. CONTENT_URI); builder. withValueBackReference (StructuredName. RAW_CONTACT_ID, 0); builder. withValue (Data. MIMETYPE, StructuredName. CONTENT_ITEM_TYPE); builder. withValue (StructuredName. DISPLAY_NAME, "Custom contact name"); operationList. add (builder. build (); builder = ContentProviderOperation. newInsert (Data. CONTENT_URI); builder. withValueBackReference (Phone. RAW_CONTACT_ID, 0); builder. withValue (Data. MIMETYPE, Phone. CONTENT_ITEM_TYPE); builder. withValue (Phone. NUMBER, "phonenumber of the contact"); builder. withValue (Data. IS_PRIMARY, 1); operationList. add (builder. build (); try {getContentResolver (). applyBatch (ContactsContract. AUTHORITY, operationList);} catch (RemoteException e) {e. printStackTrace ();} catch (Operation ApplicationException e) {e. printStackTrace ();} 23 select an image Intent intent = new Intent (Intent. ACTION_GET_CONTENT); intent. addCategory (Intent. CATEGORY_OPENABLE); intent. setType ("image/*"); startActivityForResult (intent, 0); 24 call the camera of the Android device, and set the storage location after taking the photo. Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); intent. putExtra (MediaStore. EXTRA_OUTPUT, Uri. fromFile (new File (Environment. getExternalStora GeDirectory (). getAbsolutePath () + "/cwj", android123 + ". jpg "); // save it to the cwjfolder on the sdcard card, with the file name android123.jpg format startActivityForResult (intent, 0); 25 search for the specified package name on the market, for example, search for com. android123.cwj is written as follows Uri uri = Uri. parse ("market: // search? Q = pname: com. android123.cwj "); Intent intent = new Intent (Intent. ACTION_VIEW, uri); startActivity (intent); 26 get the File information and use the corresponding software to open view plainprivate void openFile (File f) {Intent intent Intent = new intent (); intent. addFlags (Intent. FLAG_ACTIVITY_NEW_TASK); intent. setAction (android. content. intent. ACTION_VIEW); String type = getMIMEType (f); intent. setDataAndType (Uri. fromFile (f), type); startActivity (intent);} private String getMIMEType (File f) {String end = f. getName (). substring (f. getName (). lastIndexOf (". ") + 1, f. getName (). length ()). toLowerCase (); String type = ""; if (end. equals ("mp3") | end. equals ("aac") | end. equals ("aac") | end. equals ("amr") | end. equals ("mpeg") | end. equals ("mp4") {type = "audio";} else if (end. equals ("jpg") | end. equals ("gif") | end. equals ("png") | end. equals ("jpeg") {type = "image";} else {type = "*";} type + = "/*"; return type;

 

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.