android使用intenet调用系统服务
1:调用游览器
Uri uri = Uri.parse("http://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
2:电话呼叫功能
Uri uri = Uri.parse("tel:10086");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
3:发送短信功能
Uri uri = Uri.parse("smsto:10086");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("sms_body", "hello andorid");
startActivity(intent);
4:播放多媒体
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/01.mp3");
intent.setDataAndType(uri, "audio/mp3");
startActivity(intent);
5:安装apk文件
String filename = Environment.getExternalStorageDirectory()+"/a.apk";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(filename)), "application/vdn.android.package-archive");
startActivity(intent);
6:卸载应用程序
Uri uri = Uri.fromParts("package", "com.dooodev.a", null);
Intent intent = new Intent(Intent.ACTION_DELETE,uri);
startActivity(intent);
7:访问联系人
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(android.provider.ContactsContract.Contacts.CONTENT_URI);
startActivity(intent);
8:从图库选择图片
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
startActivityForResult(intent, 0);
如果想要取得图片
protected void onActivityResult(int requestCode,int resultcode,Intent date)
{
if(resultcode==Activity.RESULT_OK&&requestCode==0)
{
Uri uri = date.getData();
Toast.makeText(this, uri.getPath(), Toast.LENGTH_SHORT).show();
ContentResolver contentResolver = this.getContentResolver();
try {
Bitmap bitmap = BitmapFactory.decodeStream(contentResolver.openInputStream(uri));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}