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 ...
随机推荐
- get方式编码问题解决方案 转载
我们的内容使用GET方式发送,就会在URL后面带上内容,在游览器发来的请求经过了游览器的URI编码,发送到服务器这边,如果是struts2会经过拦截器进行URI解码,并且使用"iso8859 ...
- C#遍历窗体控件(原文出自http://www.liangshunet.com/ca/201403/286434593.htm)
一.C#遍历窗体控件 主要遍历属于窗体(Form)的控件(Controls),假如窗体中有 Panel.Button 和 TextBox 控件,遍历代码如下: /// <summary> ...
- php之分页类代码
/* 思路 1.把地址栏的URL获取 2.分析URL中的query部分--就是?后面传参数的部分 3.query部分分析成数组 4.把数组中的page单元,+1,-1,形成2个新的数组 5.再把新数组 ...
- rpmbuild构建包时的宏定义的赋值
rpmbuild -bb SPECS/git.spec --define="_topdir `pwd`" rpmbuild --rebuild SRPMS/git.src.rp ...
- openshif ssh proxy
最近google又被墙了.没办法 1:注册一个openshift账号.申请注册一个app,获取一个免费主机. https://www.openshift.com/ 2:去PuTTY官方网站下载pL ...
- objective-c(初始化)
objective-c(初始化) 创建对象 (编程语言 Objective-C 2.0) 1.类对象与实例化 类的定义完成后,编译器在内存中自动生成唯一的类对象,实例对象都是通过调用类对象的类方法生成 ...
- cf B Three matrices
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; ][] ...
- 温习H3C S5500的VLAN配置
这,才是我想要的... ACCESS还是TRUNK TYPE?
- 如何给Qlabel添加clicked属性(覆盖mousePressEvent,处理QMouseEvent消息,反正是软绘制,想怎么样就怎么样)
clickedLabel.h #ifndef CLICKLABEL_H #define CLICKLABEL_H #include <QLabel> #include <QMouse ...
- 模态运行EXE程序
function ExecShowModal(APath: PChar; ACmdShow: Integer; ATimeout: Longword): Integer; var vStartupIn ...