Android Intent调用 Uri的方法总结
作者:lqh 时间:2021-11-13 22:46:53
Android Intent调用 Uri的方法总结
//调用浏览器
Uri uri = Uri.parse("");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
//显示某个坐标在地图上
Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);
//显示路径
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);
//拨打电话
Uri uri = Uri.parse("tel:10086");
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
Uri uri = Uri.parse("tel.10086");
Intent it =new Intent(Intent.ACTION_CALL,uri);
需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 这个权限到androidmanifest.xml
//发送短信或彩信
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", "The SMS text");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
//发送短信
Uri uri = Uri.parse("smsto:10086");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "cwj");
startActivity(it);
//发送彩信
Uri uri = Uri.parse("content://media/external/images/media/23");
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra("sms_body", "some text");
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType("image/png");
startActivity(it);
//发送邮件
Uri uri = Uri.parse("mailto:android123@163.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, android123@163.com);
it.putExtra(Intent.EXTRA_TEXT, "The email body text");
it.setType("text/plain");
startActivity(Intent.createChooser(it, "Choose Email Client"));
Intent it=new Intent(Intent.ACTION_SEND);
String[] tos={"me@abc.com"};
String[] ccs={"you@abc.com"};
it.putExtra(Intent.EXTRA_EMAIL, tos);
it.putExtra(Intent.EXTRA_CC, ccs);
it.putExtra(Intent.EXTRA_TEXT, "The email body text");
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.setType("message/rfc822");
startActivity(Intent.createChooser(it, "Choose Email Client"));
//播放媒体文件
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/cwj.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//卸载APK
Uri uri = Uri.fromParts("package", strPackageName, null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
//卸载apk 2
Uri uninstallUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
//安装APK
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
//播放音乐
Uri playUri = Uri.parse("file:///sdcard/download/sth.mp3");
returnIt = new Intent(Intent.ACTION_VIEW, playUri);
//发送附件
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/cwj.mp3");
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(it, "Choose Email Client"));
//market上某个应用信,pkg_name就是应用的packageName
Uri uri = Uri.parse("market://search?q=pname:pkg_name");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//market上某个应用信息,app_id可以通过www网站看下
Uri uri = Uri.parse("market://details?id=app_id");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//调用搜索
Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"android123")
startActivity(intent);
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
来源:http://blog.csdn.net/bdmh/article/details/30491017
标签:Android,Intent,Uri
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#使用Socket实现局域网聊天
2021-07-20 02:13:20
![](https://img.aspxhome.com/file/2023/7/119467_0s.jpg)
Java效率提升神器jOOR
2022-06-07 20:46:16
基于JavaMail实现邮件发送
2022-06-21 02:28:06
Android基础教程数据存储之文件存储
2023-08-05 18:18:10
![](https://img.aspxhome.com/file/2023/3/86743_0s.png)
Java高并发BlockingQueue重要的实现类详解
2021-06-20 12:08:24
在Mybatis中使用自定义缓存ehcache的方法
2022-02-24 17:27:35
Java Validation Api使用方法实例解析
2023-05-16 05:44:58
![](https://img.aspxhome.com/file/2023/7/119107_0s.png)
C++求四个正整数最大公约数的方法
2023-02-04 12:09:19
![](https://img.aspxhome.com/file/2023/9/114929_0s.jpg)
C#入门之定义类成员与接口实现
2023-05-25 09:50:58
浅析C# 函数的传值与传址
2023-11-22 04:46:57
![](https://img.aspxhome.com/file/2023/0/71730_0s.png)
C#先判断是否存在再创建文件夹或文件与递归计算文件夹大小
2023-07-29 00:04:58
![](https://img.aspxhome.com/file/2023/6/89806_0s.png)
VS2013创建Windows服务与调试服务的图文方法
2022-01-15 02:23:14
![](https://img.aspxhome.com/file/2023/6/111246_0s.png)
使用注解@Validated和BindingResult对入参进行非空校验方式
2022-09-16 11:30:44
![](https://img.aspxhome.com/file/2023/5/66215_0s.png)
SpringBoot实现过滤器、拦截器与切片的实现和区别
2023-04-28 22:51:04
![](https://img.aspxhome.com/file/2023/1/84641_0s.png)
C#中winform实现自动触发鼠标、键盘事件的方法
2022-02-23 22:50:58
关于C语言动态内存管理介绍
2022-07-31 17:05:32
![](https://img.aspxhome.com/file/2023/2/124022_0s.png)
Java多线程、进度条实现赛马实验的示例代码
2023-08-20 04:44:10
归并排序的原理及java代码实现
2021-11-18 13:51:10
![](https://img.aspxhome.com/file/2023/4/75484_0s.gif)
c# 实现MD5,SHA1,SHA256,SHA512等常用加密算法源代码
2021-11-22 22:18:24
Java判断所给年份是平年还是闰年
2023-10-21 17:48:59