Android jump to system contact and dial-up or SMS interface _android

Source: Internet
Author: User

Now the development of the function needs to jump directly to the dial-up, contact, SMS interface and so on, looking for a lot of information, I organized a bit.

1, jump to the Dial-up interface, the code is as follows:

1) Direct dialing

Intent Intentphone = new Intent (Intent.action_call, Uri.parse ("Tel:" + phonenumber)); 
StartActivity (Intentphone);

2) jump to the Dial-up interface

Intent Intent = newintent (Intent.action_dial,uri.parse ("Tel:" + phonenumber)); 
Intent.setflags (Intent.flag_activity_new_task); 

2, jump to the contact page, use the code:

Intent Intentphone = new Intent (Intent.action_call, Uri.parse ("Tel:" + phonenumber)); 

The following content is reproduced:

Android Development Intent jump to the system application of the Dial-up interface, contact interface, SMS interface is now the development of the function need to jump directly to the dial-up, contact, SMS interface, etc., look for a lot of information, their own tidy up a bit.  

Installs an existing apk String filepath= "mnt/sdcard/abc.apk"; 
Intent Intent = new Intent (Intent.action_view); Intent.setdataandtype (Uri.parse ("file://" + FilePath), "APPLICATION/VND." 
Android.package-archive "); StartActivity (Intent)//jump directly to the installation page, but also click the button to determine the installation, or cancel install//uninstall an application String packagename= "Org.adw.launcher2" Uri Packageuri = 
Uri.parse ("Package:" +packagename);//package name, specify the application Intent uninstallintent = new Intent (Intent.action_delete, Packageuri); 
StartActivity (uninstallintent); View an application's information Uri uri=uri.parse ("package:" +packagename);//package name, specifying the application Intent intent=new Intent (" 
Android.settings.APPLICATION_DETAILS_SETTINGS ", URI);  
StartActivity (Intent);  
 2. Browse the Web page a specific URL uri uri = uri.parse ("http://xxxxxxxxxxxxxxxxxxxxxxxx"); 
Intent Intent = new Intent (Intent.action_view,uri); Add the following sentence is to start the system with the browser to open the above URL, without the following sentence, if you have more than one browser, it will pop-up let you select a browser, and then change the browser will open the Web site ... intent.setclassname ("  
 Com.android.browser "," com.android.browser.BrowserActivity "); 
StartActivity (Intent); System Setup Interface inTent intent=new Intent (); 
Intent.setclassname ("Com.android.settings", "com.android.settings.Settings");  
StartActivity (Intent); 
Back to the desktop? Intent Intent = new Intent (intent.action_main); 
Intent.addcategory (Intent.category_home); 
StartActivity (Intent);  
The system dial-up interface Intent intent= new Intent (intent.action_dial); 
Intent.setclassname ("Com.android.contacts", "com.android.contacts.DialtactsActivity");    
StartActivity (Intent);  
System call Record interface Intent Intent =new Intent ();  
Intent.setaction ("Android.intent.action.CALL_BUTTON"); 
StartActivity (Intent);   
 dial-up uri uri = uri.parse ("tel:xxxxxx");    
 Intent Intent = new Intent (intent.action_dial, URI);  
StartActivity (Intent);  
 Starts the Dial-up interface, specifies that the class name package name is the system's dial-up interface dialtactsactivity Intent intent= new Intent ("Android.intent.action.DIAL"); 
Intent.setclassname ("Com.android.contacts", "com.android.contacts.DialtactsActivity");  
StartActivity (Intent); 
System Contact Person Interface peopleactivity Intent intent001 = new Intent (); Intent001.setclassname ("Com.aNdroid.contacts "," com.android.contacts.activities.PeopleActivity ");  
StartActivity (intent001); 
System Search Interface searchactivity Intent intent002=new Intent (); 
Intent002.setclassname ("Com.android.quicksearchbox", "com.android.quicksearchbox.SearchActivity"); 
StartActivity (intent002); 
Start SMS Inbox interface, specify the package name, class name Intent intent4 = new Intent (); 
Intent4.setclassname ("Com.android.mms", "com.android.mms.ui.ConversationList"); 
 StartActivity (INTENT4);  
 Start contact interface, not good Intent Intent = new Intent ();  
 Intent.setaction (Intent.action_pick);  
 Intent.setdata (Contacts.People.CONTENT_URI); 
StartActivity (Intent);  
Insert Contact person Intent intent=newintent (intent.action_edit,uri.parse ("content://com.android.contacts/contacts/" + "1")); 
StartActivity (Intent);  
To the Contact list interface Intent Intent = new Intent (intent.action_insert_or_edit);  
Intent.settype ("Vnd.android.cursor.item/person");  
Intent.settype ("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.PHONE_TYPE, 3); 
Start SMS Inbox interface, specify the package name, class name Intent Intent = new Intent (); 
Intent.setclassname ("Com.android.mms", "com.android.mms.ui.ConversationList"); 
StartActivity (Intent);  
Start the edit SMS 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); ---------------------------------------------------------------2----------------------------------------------- -------------------------------------------------------------------------------The features now in development need to jump directly to dial-up, contact, SMS interface, etc. 
 Looking for a lot of information, I organized a bit.  
 First, we first look at the Dial-up interface, 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, but if it's a jump to the application, use the code: Intent intent= New Intent ("Android.intent.action.DIAL"); 
Intent.setclassname ("Com.android.contacts", "com.android.contacts.DialtactsActivity");  
To the call logging interface: 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);   
To application: Intent intent= new Intent ("Com.android.contacts.action.LIST_STREQUENT"); 
Intent.setclassname ("Com.android.contacts", "com.android.contacts.DialtactsActivity");   
Invoke Contact interface: Intent Intent = new Intent ();   
Intent.setaction (Intent.action_pick);   
Intent.setdata (Contacts.People.CONTENT_URI);   
StartActivity (Intent); Insert Contact person Intent intent=new Intent (intent.action_edit,uri.parse ("Content://com.android.contacts/contacts/"+" 1 "));  
StartActivity (Intent);  
To the Contact list interface Intent Intent = new Intent (intent.action_insert_or_edit);  
Intent.settype ("Vnd.android.cursor.item/person");  
Intent.settype ("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.PHONE_TYPE, 3);  
Copy code to SMS 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 application: Intent Intent = new Intent ("Android.intent.action.CONVERSATION");  
StartActivity (Intent); Here are some other ways to find it online: 1. Intent Intent = new Intent () from Google search content;   
Intent.setaction (Intent.action_web_search);   
Intent.putextra (Searchmanager.query, "SearchString") startactivity (intent);   
2. Browse Web page 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%20startLng&daddr=endLat%20endLng   
&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);  
The difference is that the test will be known.    
6. Call the text message program 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 each other to send SMS);   
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.android-dir/mms-sms");   
StartActivity (mintent);    
7. Send sms URI uri = uri.parse ("smsto: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.putextra (Messaging.key_action_sendto_compose_mode, true);   
Mmsintent.putextra (Messaging.key_action_sendto_exit_on_sent, true); StartActivity (mmsintent); <span style= "font-family:simsun;white-space:normal; Background-color:rgb (255, 255, 255); > </span> 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 StringBuilder ();   
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 ());   
Intent.putextra (Messaging.key_action_sendto_compose_mode, Composemode);   
Intent.putextra (Messaging.key_action_sendto_exit_on_sent, exitonsent);   
StartActivity (Intent);   
9. Send email URI 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, "The 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.settype ("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);   
Uri 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 apk uri uri = uri.fromparts ("package", strpackagename, NULL);    
Intent it = new Intent (Intent.action_delete, URI);  
StartActivity (IT);   
12.install apk Uri Installuri = uri.fromparts ("package", "XXX", null);  
Returnit = new Intent (intent.action_package_added, Installuri);   
     13. Open the 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.Media.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.action_image_capture);   
     Inttphoto.putextra (Mediastore.extra_output, Photouri); 
Startactivityforresult (Inttphoto, 10);   
    14. Choose Pictures from gallery Intent i = new Intent ();   
    I.settype ("image/*");   
    I.setaction (intent.action_get_content);   
Startactivityforresult (i, 11);   
15. Turn on the recorder Intent mi = new Intent (media.record_sound_action); 
StartActivity (MI);      
16. Display 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 and find the ID//by cLicking on your application in Market home//page, and notice the ID from the address Bar<span style= "Font-famil Y:simsun;white-space:normal; Background-color:rgb (255, 255, 255);
> </span> just look for the app ID, and it turns out that the URI uri = Uri.parse ("market://details?id=<packagename>") can be used with package name.      
This is much simpler. 17 Find 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 a application<span style= "font-family:simsun;white-space:normal; Background-color:rgb (255, 255, 255);   
     > </span> 18 Open Contact List Intent i = new Intent ();   
     I.setaction (intent.action_get_content);   
     I.settype ("Vnd.android.cursor.item/phone"); 
     Startactivityforresult (i, request_text);   
     Uri uri = uri.parse ("Content://contacts/people");   
     Intent it = new Intent (Intent.action_pick, URI);  
Startactivityforresult (it, request_text); 19Open 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", "short Message");   
Cv.put ("Body", "Short message content"); 
Getcontentresolver (). Insert (Uri.parse ("Content://sms/inbox"), CV);  
21 Check Cursor Cursor from SIM card or contact person;  
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, NULL, NULL); 
while (Cursor.movetonext ()) {int peopleid = Cursor.getcolumnindex (people._id);  
int nameId = Cursor.getcolumnindex (people.name); 
int Phoneid = Cursor.getcolumnindex (People.number);} To view a contact, of course, this is Action_view, if you change the action to Action_pick for the selection and return, of course, when processing intent, returnNeed to use Startactivityforresult Uri Personuri = Contenturis.withappendedid (People.content_uri, ID); The last ID parameter is the database BaseID in the contact provider, that is, which row 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 added to contact: contentvalues CV = new Contentvalues ();  
arraylist<contentprovideroperation> operationlist = new arraylist<contentprovideroperation> ();  
Contentprovideroperation.builder Builder = Contentprovideroperation.newinsert (Rawcontacts.content_uri);  
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 person");  
Builder.withvalue (data.is_primary, 1);  
Operationlist.add (Builder.build ());  
    try {getcontentresolver (). Applybatch (contactscontract.authority, operationlist);  
    catch (RemoteException e) {e.printstacktrace ();  
   catch (Operationapplicationexception e) {e.printstacktrace ();   
23 Select a picture Intent Intent = new Intent (intent.action_get_content);  
Intent.addcategory (intent.category_openable);  
Intent.settype ("image/*"); 
Startactivityforresult (Intent, 0);  
24 invoke the camera of the Android device and set the location after the photo to be stored Intent Intent = new Intent (mediastore.action_image_capture); Intent.putextra (Mediastore.extra_output, Uri.fromfile, new File (environment. getExternalStorageDirectory (). GetAbsolutePath () + "/CWJ", android123 + ". jpg"));  
The storage location is the CWJ folder on the SDcard card, the file name is android123.jpg format startactivityforresult (intent, 0); 25 searches the market for the specified package name, such as the search COM.ANDROID123.CWJ, 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 the private void OpenFile (file f) {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.GETN   
 Ame (). 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; }  
--------------------------------------------------------------- 
----------------------------------------------- -------------------------------------------------------------------------------The features now in development need to jump directly to dial-up, contact, SMS interface, etc. 
Looking for a lot of information, I organized a bit. 
1, jump to the Dial-up interface, the code is as follows: 1 direct dial Intent intentphone = new Intent (Intent.action_call, Uri.parse ("Tel:" + phonenumber)); 
StartActivity (Intentphone); 
2 Jump to the Dial-up interface Intent Intent = newintent (Intent.action_dial,uri.parse ("Tel:" + phonenumber)); 
Intent.setflags (Intent.flag_activity_new_task); 
StartActivity (Intent); 
2, jump to the contact page, use the code: Intent intentphone = new Intent (Intent.action_call, Uri.parse ("Tel:" + phonenumber)); 
StartActivity (Intentphone); ---------------------------------------------------------------3----------------------------------------------- ---------------- 
---------------------------------------------------------------  

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.