intent和intentfilter
intent 和intent Filters
startActivity()的机制
用到了IBinder ipc 用到了进程间通讯机制
activity有四种LaunchMode
当startActivity()的时候不知道启动的是不是和自己的activity在一个
进程中。所以要用 IPC 进程间通讯来调用
简单的使用方法
1
A.class中
|
1
2
3
|
Intentnew Intent(A.this,class);intent.putExtra("sundy.demo", "你好");startActivity(intent); |
B.class中
|
1
2
3
|
Intentthis.getIntent();String value"key");Toast.makeText(this,1).show(); |
2
A.class中
|
1
2
3
4
|
Intentnew Intent();intent.putExtra("key", "123");intent.setAction("com.wang.cn");startActivity(intent); |
B。
class中
.
|
1
2
3
|
Intentthis.getIntent();String value"key");Toast.makeText(this,1).show(); |
要在mainfest中设置B。clas的activity中的intent-filter的action中设置
|
1
2
3
4
5
6
7
|
<activity".B" > <intent-filter> <action"com.wang.cn" /> <category"android.intent.category.DEFAULT" /> </intent-filter> </activity> |
必须写上 <category android:name="android.intent.category.DEFAULT" />这一句不然会报错。。
3. 简单的打电话 代码
|
1
2
3
4
5
|
Intentnew Intent();intent.setAction(Intent.ACTION_DIAL);intent.setData(Uri.parse("tel:12345645555"));startActivity(intent); |
setAction和setData都是系統定義好 。這裡仅仅說下使用方法
4.获取data中的值
A。class中
|
1
2
3
4
|
Intentnew Intent();intent.setAction("com.wang.cn");intent.setData(Uri.parse("tel:12345645555"));startActivity(intent); |
B。class中
|
1
2
3
4
|
Intentthis.getIntent();String uriToast.makeText(this,1).show(); |
setAction和setData都是系統定義好 。這裡仅仅說下使用方法
|
1
2
3
4
5
6
7
8
9
10
|
<activity".Rose" > <intent-filter> <action"com.wang.cn" /> <category"android.intent.cat /> <data"tel" > </data> </intent-filter> </activity> |
5.startActivityForResult 方法
A。
class中
|
1
2
3
|
Intentnew Intent();intent.setClass(A.this,B.class);startActivityForResult(intent, 123); |
在A。
clas的activity中 导入系统的onActivityResult方法
|
1
2
3
4
5
6
7
8
9
|
@Override protected void onActivityResult(int requestCode, int resultCode, // super.onActivityResult(requestCode, if (resultCode321) String value"name"); Toast.makeText(this,1).show(); } } |
B.class中
|
1
2
3
4
5
6
7
8
9
10
11
|
button.setOnClickListener(new OnClickListener() @Override public void onClick(View Intentthis.getIntent(); intent.putExtra("name", "111111111"); setResult(321, finish(); } }); |
当resultCode一样的时候 回传值成功。。
6.intent 传递 对象 类 等等
intent和intentfilter的更多相关文章
- Intent和IntentFilter详解
Intent用于启动Activity,Service, 以及BroadcastReceiver三种组件, 同时还是组件之间通信的重要媒介. 使用Intent启动组件的优势1, Intent为组件的启动 ...
- [转]android笔记--Intent和IntentFilter详解
Intent用于启动Activity, Service, 以及BroadcastReceiver三种组件, 同时还是组件之间通信的重要媒介. 使用Intent启动组件的优势1, Intent为组件的启 ...
- android学习日记20--连接组件之Intent和IntentFilter
上次刚了解完Android的四大组件,现在学习组件间通信的Intent和IntentFilter 一.Intent 1.简述 Intent(意图)在应用程序运行时连接两个不同组件,是一种运行时的绑定机 ...
- Intent及IntentFilter具体解释
Intent用于启动Activity, Service, 以及BroadcastReceiver三种组件, 同一时候还是组件之间通信的重要媒介. 使用Intent启动组件的优势 1, Intent为组 ...
- Android应用程序组件之间的通信Intent和IntentFilter
Android应用程序的基本组件,这些基本组建除了Content Provider之外,几乎全部都是依靠Intent对象来激活和通信的. 下面介绍Intent类,并通过例子来说明Intent一般用法 ...
- Android的Intent和IntentFilter应用说明一例
很多人对文档中的Intent和IntentFilter不理解是什么意思,我这里举例解释下. Intent字面意思就是目标,目的.通俗一点,需要达成某些目标,则需要提供一些动作,这些目标的分类,以及达成 ...
- Intent和IntentFilter简介
Intent和IntentFilter简介 Intent和IntentFilter简介 意图Intent分类: 显式意图:利用class找到对方,在同一个应用程序类可以方便使用,但是在不同的应用程序无 ...
- android笔记--Intent和IntentFilter详解
本文转载自:https://www.cnblogs.com/liushengjie/archive/2012/08/30/2663066.html 本文转载自:https://www.cnblogs. ...
- Android开发之隐式Intent中Intent-filter的三个属性-action,category,data
使用隐式Intent时,需要使用到意图过滤器Intent-filter.Intent-filter含有三个属性:action,category,data.通过这三个属性的组合,可以启动想要启动的act ...
随机推荐
- centos 安装vnc服务
1.安装tigervnc-server yum install tigervnc-server 2.启动vnc服务 vncserver:1 [错误提示待解决bad display name " ...
- Extjs4.2.1学习笔记[更新]
心血来潮准备学习一下Extjs,就从官方网站http://extjs.org.cn/下载了最新版本4.2.1,开始从头学习,记一下笔记,让自己能够持之以恒. 先说一下基本文件类库引用吧, 每个项目一开 ...
- js+dom开发第十六天
一.css常用标签及页面布局 1.常用标签 position(定位) z-index(定位多层顺序) background(背景) text-align(针对字符自动左右居中) margin(外边距) ...
- 项目知识点.Part1
1. storyboard中添加scrollview: 先添加scrollView,进行约束 添加View 进行约束 相对于scrollView 如果水平滑动:设置vertically in Cont ...
- hiho一下103周 平衡树·Treap
平衡树·Treap 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho:小Hi,我发现我们以前讲过的两个数据结构特别相似. 小Hi:你说的是哪两个啊? 小Ho:就是二 ...
- 利用HTML5分片上传超大文件
在网页中直接上传大文件一直是个比较头疼的问题,主要面临的问题一般包括两类:一是上传时间长中途一旦出错会导致前功尽弃:二是服务端配置复杂,要考虑接收超大表单和超时问题,如果是托管主机没准还改不了配置,默 ...
- X-Plosives
uvaLive 3644:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pa ...
- 了解运行时类型信息(RTTI)
RTTI需要引用单元TypeInfo GetPropInfo 函数用于获得属性的 RTTI 指针 PPropInfo.它有四种重载形式,后面三种重载的实现都是调用第一种形式.AKinds 参数用于限制 ...
- Linux 配置多IP
这里以红帽Linux为例.假定原系统已配置一个IP,地址为:192.168.20.140,配置文件路径/etc/sysconfig/network-script/ifcfg-eth0.现在需要配置一个 ...
- session和cookie详解2
http 之session和cookie http://www.cnblogs.com/ForEverKissing/archive/2008/05/23/1205503.html Session简介 ...