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 ...
随机推荐
- TatukGIS - GisDefs - CheckDir 函数
函数名称 CheckDir 所在单元 GisDefs 函数原型 function CheckDir(const _path: String): Boolean; 函数说明 如果 _path ...
- DataTable举例
// clrTest1.cpp: 主项目文件. #include "stdafx.h" using namespace System; using namespace System ...
- C++实现base64编码(1)
下面的代码是php里面的base64编码逻辑,确实比我之前的要美观很多,我只是简单的用C++的类进行了一下封装,删除了一些没用的逻辑,基本上还是原来PHP的代码: #include <iostr ...
- HTML用法小摘录
一.网页地址栏上小图标标签添加写法: <link rel="Shortcut Icon" href="~/Content/ico/glasses.ico" ...
- phalapi
public为程序入口 Demo和MyApp为具体的实现 public为多入口 demo和myapp都是入口,但是进入后即又为单入口 list为接口文档,是自动解析程序里的注释自动生成的文档 框架执行 ...
- 应用mysql(Linux中安装)
当前 mysql 官网的安装教程,指明可以使用 yum 方式. 若在Ubuntu中安装,参考“Linux(Ubuntu)下MySQL的安装与配置”. MySQL YUM Repository MySQ ...
- BZOJ 1006 神奇的国度
Description K国是一个热衷三角形的国度,连人的交往也只喜欢三角原则.他们认为三角关系:即AB相互认识,BC相互认识,CA相互认识,是简洁高效的.为了巩固三角关系,K国禁止四边关系,五边关系 ...
- [HDOJ 5155] Harry And Magic Box
题目链接:HDOJ - 5155 题目大意 有一个 n * m 的棋盘,已知每行每列都至少有一个棋子,求可能有多少种不同的棋子分布情况.答案对一个大素数取模. 题目分析 算法1: 使用容斥原理与递推. ...
- Javascript Framework Scenario
Mobile----- zepto, jQuery Scroll------ iscrollhttp://cubiq.org/iscroll-4 jo.js widget----- jquery pl ...
- 子类化窗口控件的窗口过程(系统级替换,与直接替换控件的WndProc方法不是一回事)
要说灵活性,自然是比不上Delphi自带的覆盖WndProc,或者替换WndProc方法. unit Unit1; interface uses Windows, Messages, SysUtils ...