Intent redirects to the dial-up interface, contact interface, SMS interface, and other interfaces in the system application.
Now, the functions under development need to jump directly to the dialing, contact, text message interface, and so on. After finding a lot of information, I sorted it out myself.
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.
However, to jump to the application, use 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 page:
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 the contact interface:
Intent intent = new Intent ();
Intent. setAction (Intent. ACTION_PICK );
Intent. setData (Contacts. People. CONTENT_URI );
StartActivity (intent );
Insert contact
Intent intent = new Intent (Intent. ACTION_EDIT,
Uri. parse ("content: // com. android. contacts/" + "1 "));
StartActivity (intent );
Go to the contact list page
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 );
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 application:
Intent intent = new Intent ("android. intent. action. CONVERSATION ");
StartActivity (intent );
Other methods found on the Internet are as follows:
1. Search for content from google
Intent intent = new Intent ();
Intent. setAction (Intent. ACTION_WEB_SEARCH );
Intent. putExtra (SearchManager. QUERY, "searchString ")
StartActivity (intent );
2. Browse the webpage
Uri uri = Uri. parse ("http://www.google.com ");
Intent it = new Intent (Intent. ACTION_VIEW, uri );
StartActivity (it );
3. display a map
Uri uri = Uri. parse ("geo: 38.899533,-77.036476 ");
Intent it = new Intent (Intent. Action_VIEW, uri );
StartActivity (it );
4. Route 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 on your own.
6. Call the SMS 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 the recipient to send the 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 );
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. Select an image from gallery
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. display the detailed list of applications
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
Failed to find the app id. The package name is used.
Or Uri uri = Uri. parse ("market: // details? Id = ");
This is much simpler.
17. Search for Applications
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 application
18 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, uri );
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", "SMS content ");
GetContentResolver (). insert (Uri. parse ("content: // sms/inbox"), cv );
21. query from SIM card or contact
Cursor cursor;
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 (People. _ ID );
Int nameId = cursor. getColumnIndex (People. NAME );
Int phoneId = cursor. getColumnIndex (People. NUMBER );}
View a contact, of course, ACTION_VIEW,
If you select and change the returned action to ACTION_PICK, startActivityforResult is required for intent processing.
Uri personUri = ContentUris. withAppendedId (People. CONTENT_URI, ID );
// The last ID parameter is the database BaseID in the contact Provider, that is, the 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 add to contact:
ContentValues cv = new ContentValues ();
ArrayList OperationList = new ArrayList ();
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, "contact's phonenumber ");
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 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 location for storing the photo.
Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE );
Intent. putExtra (MediaStore. EXTRA_OUTPUT,
Uri. fromFile (new File (Environment. getExternalStorageDirectory (). getAbsolutePath () + "/cwj ",
Android123 + ". jpg ")));
// Save the position to the cwjfolder on the sdcard card. The file name is in android123.jpg format.
StartActivityForResult (intent, 0 );
25. Search for the specified package name on the market. For example, search for 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. Obtain the file information and open it with the corresponding software.
View plain
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. 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;