以下是常用到的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 fromhttp://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 fromhttp://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 androidhttp://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 androidhttp://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
分享到:
相关推荐
本文件介绍的是Anroid中Intent的使用方法,从谷歌中搜索内容;浏览网页;显示地图;路径规划;拨打电话;发送短信等简单功能实现
链接器提供了基于注释的API,以处理Android的URI路由。 该库是用kotlin编写的,生成的代码也是纯kotlin。 依存关系 将以下内容添加到您的build.gradle文件中: dependencies { api ' me.twocities:linker:0.0.5 '...
网络上看到过很多种Uri转路径的方法,可基本上都只适用于很少的Uri值,可能没有结果(例如,对于由MediaStore索引的非本地文件),也可能没有可用的结果(例如,对于可移动存储上的文件)。 解决方法 使用...
主要介绍了Android使用WebView.loadUri()打开网页的方法,结合实例形式分析了Android中WebView控件的loadUri()打开网页的使用技巧,需要的朋友可以参考下
为了在Android应用中播放视频,Android提供了VideoView控件,它就是一个位于android.widget包下的控件,它的作用与ImageView类似,只是ImageView用于显示图片,而VideoView用于播放视频。 使用VideoView播放视频的...
本文介绍了自定义Content Provider的相关内容,完全解析内容提供者的用法。Content Provider,内容提供者,相信大家对这个组件的名字都不陌生,可能是自己平时做的都是一些简单的App,所以对于Content Provider的...
3.3 使用Android SDK帮助 23 3.3.1 Android SDK API文档 23 3.3.2 Android SDK开发指南 24 3.3.3 Android SDK samples 24 3.4 使用DDMS帮助调试程序 26 3.4.1 启动DDMS 26 3.4.2 Device 28 3.4.3 Emulator ...
如何使用使用uri字符串或intent实例调用UriDispatcher#dispatch 。 @Overrideprotected void onNewIntent( final Intent intent) { super . onNewIntent(intent); UriDispatcher . dispatch( this , intent);} 称为...
1.3 Android常用开发工具的用法 10 1.3.1 创建、删除和浏览AVD 10 1.3.2 使用Android模拟器 (Emulator) 14 1.3.3 使用DDMS进行调试 15 1.3.4 Android Debug Bridge(ADB) 的用法 16 1.3.5 使用DX...
Android中的Intent是一个非常重要的类,如果对Intent不是特别了解,可以参见《详解Android中Intent的使用方法》。如果对Intent Filter不是特别了解,可以参见《详解Android中Intent对象与Intent Filter过滤匹配过程...
的 Android SDK 提供了在 Android 平台上使用 JaVa 语言进行 Android 应用开发必须的工具和 API 接口。 特性 • 应用程序框架 支持组件的重用与替换 • Dalvik Dalvik Dalvik Dalvik 虚拟机 专为移动设备优化 • ...
使用(用法) 1.项目build.gradle : repositories { maven { url 'https://dl.bintray.com/javakam/FileOperator' } } 2.依赖(dependencies) implementation 'ando.file:core:1.3.8' //核心库必选(Core ...
Android 根据经纬查看街景,这个只是学习经纬度的获取和用法,查看街景的功能需要运行条件才行,通过本源码可了解经纬度获取方法,下面是相关的代码: 重写onClick方法: EditText etLong = (EditText)...
1dialogButtonTextColor对话框按钮的文字颜色-1所有版本:点击查看使用步骤第一步: app/build.gradle进行依赖implementation 'com.azhon:appupdate:1.7.3'第二步:创建DownloadManager,更多用法请查看这里示例...
ContentResolver的使用方法:(参考《疯狂Android讲义第三版》446面) 1、调用Context的getContentResolver()获取ContentResolver对象。 2、根据需要调用ContentResolver的insert(),delete(),updata(),query方法操作...
24.4.5 使用语言方法 24.5 参考资料 24.6 小结 第25章 触摸屏 25.1 MotionEvent 25.1.1 MotionEvent 对象 25.1.2 回收MotionEvent 25.1.3 使用VelocityTracker 25.1.4 探索拖放操作 25.2...
使用InputStream 的read方法以及ByteArrayOutputStream的wirte方法 inputStream.read(buffer) outputStream.write(buffer, 0, len) outputStream.toByteArray() 最后调用disconnect()方法将HTTP连接关掉 conn....
开发工具是 android studio SDK版本是 4.3 实现过程基本是这样 ...最后,我发现要使用这个方法,还得自己继承WebChromeClient这个类把openFileChooser(ValueCallback<Uri> uploadFile)这个方法给写出来,代码如下: