Android开发笔记----Intent变量的深入了解
2015-08-04 10:54
585 查看
Intent变量是要执行的目标变量
IntentFileter是用来存组件的地址,用于确定intent所指的变量在哪,且具有过滤功能,如果只有一个,则自动执行,不只有一个需要用户选择
显试intent的使用
Intent i=new Intent();
i.setComponent(new ComponentName("com.example.intentleran", "com.example.intentleran.aty1"));
这种通过简单的new出来,并setComponent(),即设置包名和类名,显试地告诉程序,我要执行那个activity或service
隐式intent的使用
Intent i=new Intent("com.example.intentleran.intent.aty1");
这个是通过一个activity的action来调用的,这种调用时通过操作系统去寻找,符合条件的intentFilerter来实现的所以需要设置一下
<intent-filter>
<action android:name="com.example.intentleran.intent.aty1"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
在mainifest.xml中设置在<activity></activity>之间添加,以方便操作系统能根据这个intentfilter来找到要启动的activity。
IntentFileter是用来存组件的地址,用于确定intent所指的变量在哪,且具有过滤功能,如果只有一个,则自动执行,不只有一个需要用户选择
显试intent的使用
Intent i=new Intent();
i.setComponent(new ComponentName("com.example.intentleran", "com.example.intentleran.aty1"));
这种通过简单的new出来,并setComponent(),即设置包名和类名,显试地告诉程序,我要执行那个activity或service
隐式intent的使用
Intent i=new Intent("com.example.intentleran.intent.aty1");
这个是通过一个activity的action来调用的,这种调用时通过操作系统去寻找,符合条件的intentFilerter来实现的所以需要设置一下
<intent-filter>
<action android:name="com.example.intentleran.intent.aty1"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
在mainifest.xml中设置在<activity></activity>之间添加,以方便操作系统能根据这个intentfilter来找到要启动的activity。
相关文章推荐
- Android每天都爱笑应用源码
- Android--Selector、shape详解 (
- android手机出现sqlite3 not found的解决方法
- android学习之屏幕解锁
- Android 基础控件之ImageSwitcher、Gallery功能的实现
- Android中再按一次退出的实现
- Android Studio 1.3 发布
- android webview type=file文件上传,安卓端代码
- android.os.NetworkOnMainThreadException的解决方案
- 修改Android中strings.xml文件, 动态改变数据
- Android之Activity的几种跳转方式
- android开发必备日志打印工具类
- android开发必备日志打印工具类
- android开发必备日志打印工具类
- android开发必备日志打印工具类
- 修改zxing扫描二维码区域大小
- android开发常用知识点备忘录
- android 闪屏
- Android异步消息之Looper、Handler、Message、HandlerThread的关系
- android studio编译出错——Failed to resolve: com.android.support:support-v4:22.2.0