[置顶] Android(安卓)系统应用调用,intent 的使用方法总结
16lz
2021-01-24
Android常用Intent使用代码汇总:
显示网页:
[java] view plain copy- 1.Uriuri=Uri.parse("http://www.google.com");
- 2.Intentit=newIntent(Intent.ACTION_VIEW,uri);
- 3.startActivity(it);
[java] view plain copy
- 1.Uriuri=Uri.parse("geo:38.899533,-77.036476");
- 2.Intentit=newIntent(Intent.Action_VIEW,uri);
- 3.startActivity(it);
[java] view plain copy
- 1.Uriuri=Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
- 2.Intentit=newIntent(Intent.ACTION_VIEW,URI);
- 3.startActivity(it);
调用拨号程序
[java] view plain copy
- 1.Uriuri=Uri.parse("tel:xxxxxx");
- 2.Intentit=newIntent(Intent.ACTION_DIAL,uri);
- 3.startActivity(it);
- 1.Uriuri=Uri.parse("tel.xxxxxx");
- 2.Intentit=newIntent(Intent.ACTION_CALL,uri);
- 3.要使用这个必须在配置文件中加入<uses-permissionid="android.permission.CALL_PHONE"/>
调用发送短信的程序
[java] view plain copy
- 1.Intentit=newIntent(Intent.ACTION_VIEW);
- 2.it.putExtra("sms_body","TheSMStext");
- 3.it.setType("vnd.android-dir/mms-sms");
- 4.startActivity(it);
[java] view plain copy
- 1.Uriuri=Uri.parse("smsto:0800000123");
- 2.Intentit=newIntent(Intent.ACTION_SENDTO,uri);
- 3.it.putExtra("sms_body","TheSMStext");
- 4.startActivity(it);
[java] view plain copy
- 1.Uriuri=Uri.parse("content://media/external/images/media/23");
- 2.Intentit=newIntent(Intent.ACTION_SEND);
- 3.it.putExtra("sms_body","sometext");
- 4.it.putExtra(Intent.EXTRA_STREAM,uri);
- 5.it.setType("image/png");
- 6.startActivity(it);
[java] view plain copy
- 1.
- 2.Uriuri=Uri.parse("mailto:[email protected]");
- 3.Intentit=newIntent(Intent.ACTION_SENDTO,uri);
- 4.startActivity(it);
- 1.Intentit=newIntent(Intent.ACTION_SEND);
- 2.it.putExtra(Intent.EXTRA_EMAIL,"[email protected]");
- 3.it.putExtra(Intent.EXTRA_TEXT,"Theemailbodytext");
- 4.it.setType("text/plain");
- 5.startActivity(Intent.createChooser(it,"ChooseEmailClient"));
- 1.Intentit=newIntent(Intent.ACTION_SEND);
- 2.String[]tos={"[email protected]"};
- 3.String[]ccs={"[email protected]"};
- 4.it.putExtra(Intent.EXTRA_EMAIL,tos);
- 5.it.putExtra(Intent.EXTRA_CC,ccs);
- 6.it.putExtra(Intent.EXTRA_TEXT,"Theemailbodytext");
- 7.it.putExtra(Intent.EXTRA_SUBJECT,"Theemailsubjecttext");
- 8.it.setType("message/rfc822");
- 9.startActivity(Intent.createChooser(it,"ChooseEmailClient"));
[java] view plain copy
- 1.Intentit=newIntent(Intent.ACTION_SEND);
- 2.it.putExtra(Intent.EXTRA_SUBJECT,"Theemailsubjecttext");
- 3.it.putExtra(Intent.EXTRA_STREAM,"file:///sdcard/mysong.mp3");
- 4.sendIntent.setType("audio/mp3");
- 5.startActivity(Intent.createChooser(it,"ChooseEmailClient"));
[java] view plain copy
- 1.
- 2.Intentit=newIntent(Intent.ACTION_VIEW);
- 3.Uriuri=Uri.parse("file:///sdcard/song.mp3");
- 4.it.setDataAndType(uri,"audio/mp3");
- 5.startActivity(it);
- 1.Uriuri=Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,"1");
- 2.Intentit=newIntent(Intent.ACTION_VIEW,uri);
- 3.startActivity(it);
[java] view plain copy
- 1.Uriuri=Uri.fromParts("package",strPackageName,null);
- 2.Intentit=newIntent(Intent.ACTION_DELETE,uri);
- 3.startActivity(it);
调用相册
- publicstaticfinalStringMIME_TYPE_IMAGE_JPEG="image/*";
- publicstaticfinalintACTIVITY_GET_IMAGE=0;
- IntentgetImage=newIntent(Intent.ACTION_GET_CONTENT);
- getImage.addCategory(Intent.CATEGORY_OPENABLE);
- getImage.setType(MIME_TYPE_IMAGE_JPEG);
- startActivityForResult(getImage,ACTIVITY_GET_IMAGE);
调用系统相机应用程序,并存储拍下来的照片
- Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);
- time=Calendar.getInstance().getTimeInMillis();
- intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(newFile(Environment
- .getExternalStorageDirectory().getAbsolutePath()+"/tucue",time+".jpg")));
- startActivityForResult(intent,ACTIVITY_GET_CAMERA_IMAGE);
安装指定apk
[java]view plaincopy
- publicvoidsetupAPK(Stringapkname){
- StringfileName=Environment.getExternalStorageDirectory()+"/"+apkname;
- Intentintent=newIntent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.fromFile(newFile(fileName)),"application/vnd.android.package-archive");
- mService.startActivity(intent);
- }
跳转至系统联系人界面,显示所有联系人
[java] view plain copy
- Intentintent=newIntent(Intent.ACTION_VIEW,ContactsContract.Contacts.CONTENT_URI);
- startActivity(intent);
更多相关文章
- Android(安卓)Permission中英对照
- 读取Android联系人列表
- Android的常用方法(转载)
- Android(安卓)编译系统 --- 版本信息
- android应用中调用系统相应用汇总
- [转]Android虚拟电源管理驱动
- android 手机系统日期及时间的读取
- Android(安卓)WebView在4.4版本以上无法获取高度
- android root权限相关bin程序rageagainsttheca