调用系统打电话:
String phone = "110";
Intent intent = new Intent();
//系统默认的action,用来打开默认的电话界面
intent.setAction(Intent.ACTION_CALL);
//需要拨打的号码
intent.setData(Uri.parse("tel:"+phone));
startActivity(intent);
调用系统发短信:
String phone = "110";
Intent intent = new Intent();
//系统默认的action,用来打开默认的短信界面
intent.setAction(Intent.ACTION_SENDTO);
//需要发短息的号码
intent.setData(Uri.parse("smsto:"+phone));
startActivity(intent);
String phone = "110";
String content = "救命啊";
Uri uri = Uri.parse("smsto:"+phone);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", content);
startActivity(intent);
调用系统查看图像
File file=new File(path); //path为图像路径
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(file), "image/*");
startActivity(intent);
调用系统拍照
String fileName = System.currentTimeMillis() + ".jpg";
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
newImagePath = UrlPath.imgPath + fileName;
Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), fileName));
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(intent, 1);
调用系统录像
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
startActivityForResult(intent, 1);
调用系统浏览网页
String url = "http://www.baidu.com";
Uri uri = Uri.parse(url);
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);