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 ...
随机推荐
- 【实习记】2014-08-10(上)代码跟踪git的想法+归并排序的debug过程
(冒泡,选择,插入,希尔,快速,归并,堆排)周末加班学习C++,打算用C++写七大经典排序代码.发现3个月前自己写的七大经典排序代码(C Language)突然运行出错. Makefile内容 ...
- Linux nohup命令详解
nohup命令及其输出文件 ...
- html中发送邮箱的链接
- Mrakdown文本编辑器
http://www.csdn.net/article/2014-05-05/2819623 WMD WMD (wmd-editor)是一个简单轻量级的HTML编辑器,使用的是 Markdown 文本 ...
- Frame与启动流程
1. frame与bounds的区别: frame是从屏幕的左上角开始计算位置,而bounds是从新添加view左上角作为(0,0)开始计算 bounds是以自身为参考系,所以左上角的点为原点 cen ...
- !a && !b 和 !(a || b) 的故事
// awk代码,当continue执行时说明书是免费的 || )) { continue } 这段代码大概是半年前写的,半年后过来读,发现已经不理解这段代码了,虽然理解当contniue执行时意味着 ...
- BZOJ 1069 最大土地面积
Description 在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. Input 第1行一个正整数N,接下来N行,每行2个数x,y ...
- BZOJ 3572 世界树
Description 世界树是一棵无比巨大的树,它伸出的枝干构成了整个世界.在这里,生存着各种各样的种族和生灵,他们共同信奉着绝对公正公平的女神艾莉森,在他们的信条里,公平是使世界树能够生生不息.持 ...
- Color the Fence
Codeforces Round #202 (Div. 2) B:http://codeforces.com/problemset/problem/349/B 题意:给你一些颜料,然后你可以用这些颜料 ...
- Task schedule
hdu4907:http://acm.hdu.edu.cn/showproblem.php?pid=4907 题意:中文题. 题解:这一道水题,自己调了很久,并且没有注意到序列可能是乱序的,wa了好几 ...