以下是常用到的Intent的URI及其示例,包含了大部分应用中用到的共用Intent。
一、打开一个网页,类别是Intent.ACTION_VIEW
Uri uri = Uri.parse(“http://blog.3gstdy.com/”);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
二、打开地图并定位到一个点
Uri uri = Uri.parse(“geo:52.76,-79.0342″);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
三、打开拨号界面 ,类型是Intent.ACTION_DIAL
Uri uri = Uri.parse(“tel:10086″);
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
四、直接拨打电话,与三不同的是,这个直接拨打电话,而不是打开拨号界面
Uri uri = Uri.parse(“tel:10086″);
Intent intent = new Intent(Intent.ACTION_CALL, uri);
五、卸载一个应用,Intent的类别是Intent.ACTION_DELETE
Uri uri = Uri.fromParts(“package”, “xxx”, null);
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
六、安装应用程序,Intent的类别是Intent.ACTION_PACKAGE_ADDED
Uri uri = Uri.fromParts(“package”, “xxx”, null);
Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri);
七、播放音频文件
Uri uri = Uri.parse(“file:///sdcard/download/everything.mp3″);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setType(“audio/mp3″);
八、打开发邮件界面
Uri uri= Uri.parse(“mailto:admin@3gstdy.com”);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
九、发邮件,与八不同这里是将邮件发送出去,
Intent intent = new Intent(Intent.ACTION_SEND);
String[] tos = { “admin@3gstdy.com” };
String[] ccs = { “webmaster@3gstdy.com” };
intent.putExtra(Intent.EXTRA_EMAIL, tos);
intent.putExtra(Intent.EXTRA_CC, ccs);
intent.putExtra(Intent.EXTRA_TEXT, “I come from http://blog.3gstdy.com”);
intent.putExtra(Intent.EXTRA_SUBJECT, “http://blog.3gstdy.com”);intent.setType(“message/rfc882″);
Intent.createChooser(intent, “Choose Email Client”);
//发送带附件的邮件
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, “The email subject text”);
intent.putExtra(Intent.EXTRA_STREAM, “file:///sdcard/mysong.mp3″);
intent.setType(“audio/mp3″);
startActivity(Intent.createChooser(intent, “Choose Email Client”));
十、发短信
Uri uri= Uri.parse(“tel:10086″);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra(“sms_body”, “I come from http://blog.3gstdy.com”);
intent.setType(“vnd.Android-dir/mms-sms”);
十一、直接发短信
Uri uri= Uri.parse(“smsto://100861″);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”);
十二、发彩信
Uri uri= Uri.parse(“content://media/external/images/media/23″);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(“sms_body”, “3g android http://blog.3gstdy.com”);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType(“image/png”);
十三、# Market 相关
1 //寻找某个应用
Uri uri = Uri.parse(“market://search?q=pname:pkg_name”);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//where pkg_name is the full package path for an application
2 //显示某个应用的相关信息
Uri uri = Uri.parse(“market://details?id=app_id”);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//where app_id is the application ID, find the ID
//by clicking on your application on Market home
//page, and notice the ID from the address bar
十四、路径规划
Uri uri = Uri.parse(“http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en”);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//where startLat, startLng, endLat, endLng are a long with 6 decimals like: 50.123456
十五、安装指定apk
public void setupAPK(String apkname){
String fileName = Environment.getExternalStorageDirectory() + "/" + apkname;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
mService.startActivity(intent);
}
十六、进入联系人页面
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(People.CONTENT_URI);
startActivity(intent);
十七、查看指定联系人
Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, info.id);//info.id联系人ID
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(personUri);
startActivity(intent);
十八、调用相册
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);
十九、调用系统相机应用程序,并存储拍下来的照片
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);
分享到:
相关推荐
Android 常用的Intent的URI及示例 很全很强大
常用的Uri大全,对于Android开发人员来说很有用。
主要介绍了Android Intent调用 Uri的方法总结的相关资料,这里整理了Android Intent 调用Uri的常用方法,需要的朋友可以参考下
是个不错的问题,而且也是个很常用的功能。快速实现了个简单的demo,这里顺便记录一下。 实现思路 思路很直观:1、读取图片二进制数据 -> 2、转成base64字符串 -> 3、转成datauri。 关于base64的介绍,可以参考...
android意图 以下是常用到的Intent的URI及其示例,包含了大部分应用中用到的共用Intent。
• apache_lookup_uri: 获得所有的 URI 相关信息。 • apache_note: 获得及配置apache服务器的请求纪录。 • array: 建立一个新的数组。 • array_walk: 让使用者自订函数能处理数组中的每一个元素。 • arsort:...
把由输电、变电、配电设备及相应的辅助系统组成的联系发电与用电的统一整体称为电力网。
public static final Uri CONTENT_URI = Uri.parse("content://downloads/my_downloads"); /** represents downloaded file above api 11 **/ public static final String COLUMN_LOCAL_FILENAME = "local_...
基于springboot框架实现一些常用的功能
上一篇 :backhand_index_pointing_right: :rocket: :rocket:更简单的处理Android系统文件操作 :rocket:适用于Android 4.4及以上系统,兼容AndroidQ新的存储策略 :rocket:图片压缩算法参考 :backhand_index_...
本文汇集36个Android开发常用经典代码片段,包括拨打电话、发送短信、... context.startActivity( new Intent(Intent.ACTION_CALL, Uri.parse( tel: + phoneNumber))); } //跳转至拨号界面 public static void call
本文实例总结了CI框架常用经典操作类。分享给大家供大家参考,具体如下: 1. 超级对象中的URI CI_URI类的解析url的相关信息 直接使用$this->uri可以使用它的相关属性 system/core/URI.php文件中 部分常用属性: (1) ...
empty($_SERVER[“REQUEST_URI”])){ $scriptName = $_SERVER[“REQUEST_URI”]; $nowurl = $scriptName; }else{ $scriptName = $_SERVER[“PHP_SELF”]; if(empty($_SERVER[“QUERY_STRING”])) $nowurl = $script...
抖音快手URL Scheme 里面包含了抖音快手,进入直播间,进入用户,hone,等 手机中的APP都有一个沙盒,APP就是一个信息孤岛,相互是不可以进行通信的。...我们可以通过系统的OpenURL来打开该app,并可以传递一些参数。
上面URI是我们初学PHP最常用的。 www.mysite.com/blog/1 这种URI是目前最流行的URI,举个例子,比如很多读书类,电影类网站,都使用了这样的URI,这样的URI要比index.php?a=1&b=2&c=3&d=4….要简洁很多。
合法uri,邮箱,手机号码,电话号码,url地址,小写字母,大写字母,大小写字母,验证pad还是pc,身份证号码,姓名,整数,小数
常用的Uri有: 联系人信息Uri:content://com.android.contacts/contacts 联系人电话Uri:content://com.android.contacts/data/phones 联系人邮件Uri:content://com.android.contacts/data/ema
《超实用的JavaScript代码段》分为9章,包括JavaScript的一些必备知识,常用的表单处理、图片处理、内容展示、页面处理、日期处理、页面特效、移动开发等代码及其他常用代码,涉及闭包、Ajax、Data URI、DOM、BOM、...
《超实用的JavaScript代码段》分为9章,包括JavaScript的一些必备知识,常用的表单处理、图片处理、内容展示、页面处理、日期处理、页面特效、移动开发等代码及其他常用代码,涉及闭包、Ajax、Data URI、DOM、BOM、...