1 |
// 給移動客服10086撥打電話 |
2 |
Uri uri = Uri.parse( "tel:10086" ); |
3 |
Intent intent = new Intent(Intent.ACTION_DIAL, uri); |
4 |
startActivity(intent); |
01 |
// 給10086發送內容爲「Hello」的短信 |
02 |
Uri uri = Uri.parse( "smsto:10086" ); |
03 |
Intent intent = new Intent(Intent.ACTION_SENDTO, uri); |
04 |
intent.putExtra( "sms_body" , "Hello" ); |
05 |
startActivity(intent); |
06 |
// 發送彩信(至關於發送帶附件的短信) |
07 |
Intent intent = new Intent(Intent.ACTION_SEND); |
08 |
intent.putExtra( "sms_body" , "Hello" ); |
09 |
Uri uri = Uri.parse( "content://media/external/images/media/23" ); |
10 |
intent.putExtra(Intent.EXTRA_STREAM, uri); |
11 |
intent.setType( "image/png" ); |
12 |
startActivity(intent); |
1 |
// 打開Google主頁 |
2 |
Uri uri = Uri.parse( "http://www.google.com" ); |
3 |
Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
4 |
startActivity(intent); |
01 |
// 給someone@domain.com發郵件 |
02 |
Uri uri = Uri.parse( "mailto:someone@domain.com" ); |
03 |
Intent intent = new Intent(Intent.ACTION_SENDTO, uri); |
04 |
startActivity(intent); |
05 |
// 給someone@domain.com發郵件發送內容爲「Hello」的郵件 |
06 |
Intent intent = new Intent(Intent.ACTION_SEND); |
07 |
intent.putExtra(Intent.EXTRA_EMAIL, "someone@domain.com" ); |
08 |
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject" ); |
09 |
intent.putExtra(Intent.EXTRA_TEXT, "Hello" ); |
10 |
intent.setType( "text/plain" ); |
11 |
startActivity(intent); |
12 |
// 給多人發郵件 |
13 |
Intent intent= new Intent(Intent.ACTION_SEND); |
14 |
String[] tos = { "1@abc.com" , "2@abc.com" }; // 收件人 |
15 |
String[] ccs = { "3@abc.com" , "4@abc.com" }; // 抄送 |
16 |
String[] bccs = { "5@abc.com" , "6@abc.com" }; // 密送 |
17 |
intent.putExtra(Intent.EXTRA_EMAIL, tos); |
18 |
intent.putExtra(Intent.EXTRA_CC, ccs); |
19 |
intent.putExtra(Intent.EXTRA_BCC, bccs); |
20 |
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject" ); |
21 |
intent.putExtra(Intent.EXTRA_TEXT, "Hello" ); |
22 |
intent.setType( "message/rfc822" ); |
23 |
startActivity(intent); |
1 |
// 打開Google地圖中國北京位置(北緯39.9,東經116.3) |
2 |
Uri uri = Uri.parse( "geo:39.9,116.3" ); |
3 |
Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
4 |
startActivity(intent); |
5 |
// 路徑規劃:從北京某地(北緯39.9,東經116.3)到上海某地(北緯31.2,東經121.4) |
6 |
Uri uri = Uri.parse( "http://maps.google.com/maps?f=d&saddr=39.9 116.3&daddr=31.2 121.4" ); |
7 |
Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
8 |
startActivity(intent); |
1 |
Intent intent = new Intent(Intent.ACTION_VIEW); |
2 |
Uri uri = Uri.parse( "file:///sdcard/foo.mp3" ); |
3 |
intent.setDataAndType(uri, "audio/mp3" ); |
4 |
startActivity(intent); |
5 |
6 |
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1" ); |
7 |
Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
8 |
startActivity(intent); |
1 |
// 打開拍照程序 |
2 |
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
3 |
startActivityForResult(intent, 0 ); |
4 |
// 取出照片數據 |
5 |
Bundle extras = intent.getExtras(); |
6 |
Bitmap bitmap = (Bitmap) extras.get( "data" ); |
01 |
// 獲取並剪切圖片 |
02 |
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); |
03 |
intent.setType( "image/*" ); |
04 |
intent.putExtra( "crop" , "true" ); // 開啓剪切 |
05 |
intent.putExtra( "aspectX" , 1 ); // 剪切的寬高比爲1:2 |
06 |
intent.putExtra( "aspectY" , 2 ); |
07 |
intent.putExtra( "outputX" , 20 ); // 保存圖片的寬和高 |
08 |
intent.putExtra( "outputY" , 40 ); |
09 |
intent.putExtra( "output" , Uri.fromFile( new File( "/mnt/sdcard/temp" ))); // 保存路徑 |
10 |
intent.putExtra( "outputFormat" , "JPEG" ); // 返回格式 |
11 |
startActivityForResult(intent, 0 ); |
12 |
// 剪切特定圖片 |
13 |
Intent intent = new Intent( "com.android.camera.action.CROP" ); |
14 |
intent.setClassName( "com.android.camera" , "com.android.camera.CropImage" ); |
15 |
intent.setData(Uri.fromFile( new File( "/mnt/sdcard/temp" ))); |
16 |
intent.putExtra( "outputX" , 1 ); // 剪切的寬高比爲1:2 |
17 |
intent.putExtra( "outputY" , 2 ); |
18 |
intent.putExtra( "aspectX" , 20 ); // 保存圖片的寬和高 |
19 |
intent.putExtra( "aspectY" , 40 ); |
20 |
intent.putExtra( "scale" , true ); |
21 |
intent.putExtra( "noFaceDetection" , true ); |
22 |
intent.putExtra( "output" , Uri.parse( "file:///mnt/sdcard/temp" )); |
23 |
startActivityForResult(intent, 0 ); |
1 |
// 打開Google Market直接進入該程序的詳細頁面 |
2 |
Uri uri = Uri.parse( "market://details?id=" + "com.demo.app" ); |
3 |
Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
4 |
startActivity(intent); |
1 |
Uri uri = Uri.fromParts( "package" , "com.demo.app" , null ); |
2 |
Intent intent = new Intent(Intent.ACTION_DELETE, uri); |
3 |
startActivity(intent); |
1 |
// 進入無線網絡設置界面(其它能夠觸類旁通) |
2 |
Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); |
3 |
startActivityForResult(intent, 0 ); |