Intent和IntentFilter
来源:互联网 发布:开心的网络用语怎么说 编辑:程序博客网 时间:2024/06/05 08:12
一、Intent对象描述
android的应用程序包含三种重要组件:Activity、Server、BroadcastReceiver都是依靠Intent来启动的,Intent实现了封装程序启动程序的意图。
Intent对象大致包含Component、Action、Category、Data、Type、Extra和Flag
二、Intent的属性及intent-filter配置
2.1、ComponentName对象
在主Actvity使用
Intent intent=new Intent();ComponentName comName=new ComponentName(MainActivity.this,OneActivity.class);intent.setComponent(comName);startActivity(intent);
新建一个OneActivity类获取基本信息
ComponentName conName= getComponentName(); oneEdit.setText("PackageName="+conName.getPackageName()+"\n"+"ClassName"+conName.getClassName());
获取之后的结果
2.2、Action、Category属性与intent-filter配置
Action代表一个Intent的抽象动作,而Category可以说是这个Action的附加属性
可以直接设置行为来对启动一个Activity
Intent intent=new Intent(); intent.setAction("android.intent.action.KAISHIKUAIDIAN");startActivity(intent);
我们可以用以下方法来获取启动该Activity的Action和Category
getIntent().getAction()
getIntent().getCategories()
可以利用Intent来获取电话簿,同时获取系统联系人是需要权限的,查看不用
//权限<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>//代码Intent intent=new Intent();intent.setAction(Intent.ACTION_GET_CONTENT);intent.setType("vnd.android.cursor.item/phone");startActivity(intent);
2.3、Data、Type属性与intent-filter配置
Data属性通常用于向A窗体哦你属性提供操作的数据,Data属性接受一个Uri对象
Uri字符串满足以下格式
scheme://host:port/path
先调用setType那么就会被setData覆盖,反之则相反
intent.setData(Uri.parse("lee:www.fkjava.org:8888/test"));intent.setType("vnd.android.cursor.item/phone");
只有使用才可以同时存在
intent.setDataAndType()
Extra可以在不同的Activity之间传递数据是个经常使用的属性
1 0
- Intent 和IntentFilter
- Intent 和IntentFilter
- Intent和IntentFilter详解
- Intent 和 IntentFilter
- Intent 和 IntentFilter
- intent和intentfilter详解
- Intent和IntentFilter详解
- Intent和IntentFilter详解
- interView - Intent和IntentFilter
- Intent和IntentFilter
- Intent和IntentFilter详解
- Intent和IntentFilter详解
- intent和intentfilter
- Intent和IntentFilter详解
- Intent和IntentFilter详解
- Intent和IntentFilter
- Intent和IntentFilter详解
- Intent和IntentFilter详解
- python程序打包loggingconf问题
- CSS揭秘--笔记--紧贴底部的页脚
- PAT A1039
- jquery对json 键值对或数组的增加、删除、遍历操作
- 云计算安全相关领域
- Intent和IntentFilter
- C++里中文转拼音那点事
- 实训之前,简单总结一下
- mybatis处理and、or关系的方法
- 改变多边形窗口的时机;SetWindowRgn;CreatePolygonRgn;POINT;PolyDraw
- ios9新特性之关键字
- Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
- JAVA基本数据类型介绍
- leetcode-46-permutations 搜索