Intent 的用法
1、用Context指定
Intent i=new Intent(context,Receivered.class);
context.startActivity(i);
2、通过配置指定
<activity android:name="com.neusoft.android.Demo.photo.TestActivity">
<intent-filter>
<action android:name="test_action"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Intent i = new Intent();
i.setAction("test_action");
this.startActivity(i);
3、直接指定
下面列出几种Intent 的用法
显示网页:
Uri uri = Uri.parse("http://www.google.com");
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=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
Intent it = new Intent(Intent.ACTION_VIEW,URI);
startActivity(it);
拨打电话:
调用拨号程序
Uri uri = Uri.parse("tel:xxxxxx");
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
Uri uri = Uri.parse("tel.xxxxxx");
Intent it =new Intent(Intent.ACTION_CALL,uri);
要使用这个必须在配置文件 中加入<uses-permission id="android .permission.CALL_PHONE" />
发送SMS/MMS
调用发送短信 的程序
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:0800000123");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "The SMS text");
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);
发送Email
Uri uri = Uri.parse("mailto:xxx@abc.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, "me@abc.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_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(it, "Choose Email Client"));
播放 多媒体
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/song.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);
Intent i = new Intent(Test.this, TestB.class);
this.startActivity(i);
转载于:https://www.cnblogs.com/wzh206/archive/2010/04/28/1722773.html
Intent 的用法相关推荐
- 安卓基础之Intent的用法
Intent的用法 意图的分类和用法: 隐式意图:通过指定一组数据或者动作实现 Intent intent=new Intent(); intent.setAction(""); ...
- Android 监听home键(android:launchMode=singleTask 与 onNewIntent(Intent intent) 的用法
android:launchMode="singleTask" 和 onNewIntent(Intent intent)两个特性,现总结一下经验: android:launchMo ...
- 【Android】Android中Intent的用法总结
转载▼ 来源:http://blog.sina.com.cn/s/blog_5f1fe33f0100n5e1.html Intent只在Android中特有,我把它比作一种运载工具,就像飞机一样,会 ...
- [安卓] 7、页面跳转和Intent简单用法
这里有一个layout资源,2个activity.首先在MainActivity.java中实例化按钮和添加按钮监听绑定都是我们知道的,这里要注意的是第22行Intent intent = new I ...
- Intent 简单用法
1.Intent有什么用? Android设计理念是鼓励减少组件间的耦合,因此Android提供了Intent (意图) ,Intent是一种消息传递机制,可以在程序内使用,也可以在程序间使用,主要用 ...
- 几种Intent 的用法
显示网页: Uri uri = Uri.parse("http://www.google.com"); Intent it = new Intent(Intent.ACTION_V ...
- Intent的用法(初步)
可视化的知识便于复习和查找(注:笔记以学习<androi第一行代码>这本书为基础) 什么是Intent?Intent在Android中的核心作用就是"跳转"(Andro ...
- Android Intent的几种用法全面总结
Android Intent的几种用法全面总结 Intent, 用法 Intent应该算是Android中特有的东西.你可以在Intent中指定程序要执行的动作(比如:view,edit,dial), ...
- putextra 传递对象_intent.putextra用法 使用Intent传递对象的两种方式 - 电脑常识 - 服务器之家...
intent.putextra用法 使用Intent传递对象的两种方式 发布时间:2017-05-22 来源:服务器之家 Intent 的用法相信你已经比较熟悉了,我们可以借助它来启动活动.发送广播. ...
最新文章
- 浅析linux容器--Docker
- C++:Windows环境下基于Eclipse配置C/C++开发环境
- 阿里文娱测试开发专家谈《算法基石:实时数据质量如何保障?》
- shell 脚本编写 if else then
- 代码质量第 5 层 - 只是实现了功能
- ASP数据库连接方式大全
- 渴望整成“卡戴珊” 澳大利亚年轻女性以整容为荣
- 大数据技术原理与应用:期末考点总结
- 通过duet软件实现ipad作为mac的副屏并修改分辨率
- 双十一大促过后怎么维护淘宝店铺数据
- D3D11 自由视角相机
- 台式计算机套什么定额,计算机电缆套定额
- ansi_up---实现后端实时日志(带颜色)前端展示
- 微信小程序拼图游戏(有效果图)
- leetcode 栈739. 每日温度
- 良心!不限速2T大容量!阿里Teambition网盘体验~~~
- 数据结构学习:哈希表
- TICKScript简介
- 实验.........
- 【论文阅读】Multi-Modal Sarcasm Detection 图文反讽识别
热门文章
- python读取xls文件详解_python3解析excel文件
- java怎么兼容switch_java – Switch语句给出了不兼容类型错误
- mysql多表成绩查询_MySQL多表数据记录查询(一)
- mysql从库执行delete停止_MySQL主库大表执行delete语句,Ctrl+C具体发生了什么分析...
- PCM复用设备主要传输什么业务?
- [渝粤教育] 西南交通大学 信号与系统A 参考 资料
- 【渝粤教育】 国家开放大学2020年春季 1366英语教学理论与实践 参考试题
- python在路径里添加变量_想学Python?那就先从头开始吧!
- python王者归来 pdf_OpenStack开源云:王者归来 PDF 下载
- nginx 电子书_Nginx最详细的反向代理配置步骤,拿去不谢