总结a:android系统常用的intent调用
来源:互联网 发布:win7照相机软件下载 编辑:程序博客网 时间:2024/06/05 00:31
Intent在英语中是意图的意思,在Android中,它是一个将要执行的动作的抽象的描述,一般来说是作为参数来使用,由Intent来协助完成android各个组件之间的通讯。Intent的用法很多,经过自己的实践和阅读网上的一些关于Intent的总结,现将其用法总结如下:
1、调用WEB浏览器
- Uri uri = Uri.parse("http://www.baidu.com");
- Intent intent = new Intent(Intent.ACTION_VIEW ,uri);
- startActivity(intent);
2、在地图上显示某个坐标
- Uri uri = Uri.parse("geo:44.899533,-77.036476");
- Intent intent = new Intent(Intent.Action_VIEW, uri);
- startActivity(intent);
3、显示路径
- Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
4、调用拨打电话界面
- Uri uri = Uri.parse("tel:10086");
- Intent intent = new Intent(Intent.ACTION_DIAL, uri);
- startActivity(intent);
5、直接拨打电话
需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 这个权限到androidmanifest.xml
- <span style="color:#000000;">Uri uri = Uri.parse("tel.10086");
- Intent intent =new Intent(Intent.ACTION_CALL, uri);</span>
6、发送短信或彩信
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.putExtra("sms_body", "The SMS text");
- intent.setType("vnd.android-dir/mms-sms");
- startActivity(intent);
7、发送短信
- Uri uri = Uri.parse("smsto:10086");
- Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
- intent.putExtra("sms_body", "test");
- startActivity(intent);
8、发送彩信
- Uri uri = Uri.parse("content://media/external/images/media/23");
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.putExtra("sms_body", "some text");
- intent.putExtra(Intent.EXTRA_STREAM, uri);
- intent.setType("image/png");
- startActivity(intent);
或者
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
- intent.putExtra("subject", "彩信主题");
- intent.putExtra("sms_body", "彩信内容");
- intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/images/11.jpg"));
- intent.setType("image/jpeg");
- startActivity(intent);
9、调用发送邮件功能
- Uri uri = Uri.parse("mailto:wuxianglong098@163.com");
- Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
- startActivity(intent);
10、发送邮件
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.putExtra(Intent.EXTRA_EMAIL, wuxianglong098@163.com);
- intent.putExtra(Intent.EXTRA_TEXT, "The email body text");
- intent.setType("text/plain");
- startActivity(Intent.createChooser(intent, "Choose Email Client"));
- Intent intent = new Intent(Intent.ACTION_SEND);
- String[] tos = {"me@abc.com"};
- String[] ccs = {"you@abc.com"};
- intent.putExtra(Intent.EXTRA_EMAIL, tos);
- intent.putExtra(Intent.EXTRA_CC, ccs);
- intent.putExtra(Intent.EXTRA_TEXT, "The email body text");
- intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
- intent.setType("message/rfc822");
- startActivity(Intent.createChooser(intent, "Choose Email Client"));
11、播放媒体文件
- Intent intent = new Intent(Intent.ACTION_VIEW);
- Uri uri = Uri.parse("file:///sdcard/cwj.mp3");
- intent.setDataAndType(uri, "audio/mp3");
- startActivity(intent);
- Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
12、卸载APK
- Uri uri = Uri.fromParts("package", strPackageName, null);
- Intent intent = new Intent(Intent.ACTION_DELETE, uri);
- startActivity(intent);
- Uri uninstallUri = Uri.fromParts("package", "xxx", null);
- Intent intent = new Intent(Intent.ACTION_DELETE, uninstallUri);
13、安装APK
- Uri installUri = Uri.fromParts("package", "xxx", null);
- Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
14、播放音乐
- Uri playUri = Uri.parse("file:///sdcard/download/sth.mp3");
- Intent intent = new Intent(Intent.ACTION_VIEW, playUri);
15、发送附件
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
- intent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/test.mp3");
- sendIntent.setType("audio/mp3");
- startActivity(Intent.createChooser(intent, "Choose Email Client"));
16、market上某个应用信,pkg_name就是应用的packageName
- Uri uri = Uri.parse("market://search?q=pname:pkg_name");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
17、market上某个应用信息,app_id可以通过www网站看下
- Uri uri = Uri.parse("market://details?id=app_id");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
18、调用搜索功能
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_WEB_SEARCH);
- intent.putExtra(SearchManager.QUERY, "android");
- startActivity(intent);
THE END!
- 总结a:android系统常用的intent调用
- 【android中级】Android 系统应用调用,intent的使用总结
- 【Android学习笔记】用intent调用常用的系统组件
- Android 系统应用调用,intent的使用总结
- Android 系统应用调用,intent的使用总结帖
- Android 系统应用调用,intent 的使用总结
- Android 系统应用调用,intent的使用总结帖
- Android 系统应用调用,intent的使用总结
- Android 系统应用调用,intent的使用总结
- Android 系统应用调用,intent 的使用方法总结
- android-调用系统的Intent
- Android的Intent系统调用
- Android 中Intent调用系统程序总结
- Android 中Intent调用系统程序总结
- Intent常用系统调用
- android 系统Intent调用
- android 系统Intent调用
- Android 系统应用调用,intent的使用
- AspNetPager简单实现Repeater
- 虚拟机 桥接 连接状态总是 断开的解决 (debian)
- 纷纷抛弃机顶盒业务,神马情况?
- libc syslog
- Lucene初级教程 (1)
- 总结a:android系统常用的intent调用
- C++笔记
- Struts2实例
- Android基本组件
- List 容器
- lua学习
- 笔记:关于shallow heap与retained heap (size)
- Android下MediaPlayerService构架介绍
- java中的抽象类和抽象方法