Several uses of Android permission Uri.parse

1. Call the web browser 
Uri myBlogUri = Uri.parse(" http://xxxxx.com "); 
returnIt = new Intent(Intent.ACTION_VIEW, myBlogUri); 

2. Map 
Uri mapUri = Uri.parse("geo:38.899533,-77.036476"); 
returnIt = new Intent(Intent.ACTION_VIEW, mapUri); 
3. Call the phone interface 
Uri telUri = Uri.parse("tel:100861" ); 
returnIt = new Intent(Intent.ACTION_DIAL, telUri); 

To use this you must add <uses-permission id="Android.permission.CALL_PHONE" /> to the configuration file 

4,直接拨打电话 
Uri callUri = Uri.parse("tel:100861"); 
returnIt = new Intent(Intent.ACTION_CALL, callUri); 
5,卸载 
Uri uninstallUri = Uri.fromParts("package", strPackageName, null); 
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri); 
6,安装 
Uri installUri = Uri.fromParts("package", "xxx", null); 
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 
7,播放 

Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3"); 
returnIt = new Intent(Intent.ACTION_VIEW, playUri); 

  1.Intent it = new Intent(Intent.ACTION_VIEW);  

  2.Uri uri = Uri.parse("file:///sdcard/download/everything.mp3""); 

  3. it.setDataAndType(uri, "audio/mp3"); 

  4. startActivity(it); 

  1. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1"); 

  2. Intent it = new Intent(Intent.ACTION_VIEW, uri); 

  3. startActivity(it); 

8. Call Send Mail 
Uri emailUri = Uri.parse("mailto:[email protected]"); 
returnIt = new Intent(Intent.ACTION_SENDTO, emailUri); 

9,发邮件 
returnIt = new Intent(Intent.ACTION_SEND); 
String[] tos = { "[email protected]" }; 
String[] ccs = { "[email protected]" }; 
returnIt.putExtra(Intent.EXTRA_EMAIL, tos); 
returnIt.putExtra(Intent.EXTRA_CC, ccs); 
returnIt.putExtra(Intent.EXTRA_TEXT, "body"); 
returnIt.putExtra(Intent.EXTRA_SUBJECT, "subject"); 
returnIt.setType("message/rfc882"); 
Intent.createChooser(returnIt, "Choose Email Client"); 

  1. Intent it = new Intent(Intent.ACTION_SEND); 

  2. it.putExtra(Intent.EXTRA_EMAIL, "[email protected]"); 

  3. it.putExtra(Intent.EXTRA_TEXT, "The email body text"); 

  4. it.setType("text/plain"); 

  5. startActivity(Intent.createChooser(it, "Choose Email Client"));  

10,发短信 
Uri smsUri = Uri.parse("tel:100861"); 
returnIt = new Intent(Intent.ACTION_VIEW, smsUri); 
returnIt.putExtra("sms_body", "yyyy"); 
returnIt.setType("vnd.android-dir/mms-sms"); 
11,直接发邮件 
Uri smsToUri = Uri.parse("smsto://100861"); 
returnIt = new Intent(Intent.ACTION_SENDTO, smsToUri); 
returnIt.putExtra("sms_body", "yyyy"); 
12,发彩信 
Uri mmsUri = Uri.parse("content://media/external/images/media/23"); 
returnIt = new Intent(Intent.ACTION_SEND); 
returnIt.putExtra("sms_body", "yyyy"); 
returnIt.putExtra(Intent.EXTRA_STREAM, mmsUri); 
returnIt.setType("image/png");

13,添加附件 

returnIt = new Intent(Intent.ACTION_SEND); 

returnIt.putExtra(Intent.EXTRA_SUBJECT, "The email subject text"); 

returnIt.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3"); 

sendIntent.setType("audio/mp3"); 

startActivity(Intent.createChooser(returnIt, "Choose Email Client")); 

14,路径规划: 

Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en"); 

returnIt = new Intent(Intent.ACTION_VIEW,URI); 

15,调用相册 

public static final String MIME_TYPE_IMAGE_JPEG = "image/*"; 

public static final int ACTIVITY_GET_IMAGE = 0; 

Intent getImage = new Intent(Intent.ACTION_GET_CONTENT); 

getImage.addCategory(Intent.CATEGORY_OPENABLE); 

getImage.setType(MIME_TYPE_IMAGE_JPEG); 

startActivityForResult(getImage, ACTIVITY_GET_IMAGE); 

16,调用系统相机应用程序,并存储拍下来的照片 

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 

time = Calendar.getInstance().getTimeInMillis(); 

intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment 

.getExternalStorageDirectory().getAbsolutePath()+"/tucue", time + ".jpg"))); 

startActivityForResult(intent, ACTIVITY_GET_CAMERA_IMAGE); 

17,搜索应用 

Uri uri = Uri.parse("market://search?q=pname:pkg_name");   

Intent it = new Intent(Intent.ACTION_VIEW, uri);   

startActivity(it);  

18,进入联系人页面 

Intent intent = new Intent(); 

intent.setAction(Intent.ACTION_VIEW); 

intent.setData(People.CONTENT_URI); 

startActivity(intent); 

19,查看指定联系人 

Uri personUri = ContentUris.withAppendedId(Pe,ple.CONTENT_URI, info.id);//info.id联系人ID 

Intent intent = new Intent(); 

intent.setAction(Intent.ACTION_VIEW); 

intent.setData(personUri);

startActivity(intent); 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326415764&siteId=291194637