【android】:android之使用Intent
2016-05-26 13:07
573 查看
android使用intent这个是通过标签进行定位的
比如说:
在 标签中我们指明了当前活动可以响应com.example.activitytest.ACTION_START 这个action
然后是在设置listener里面进行相关操作:
语法为:
Intent intent = new Intent(“com.example.test.ACTION_START”);
startActivity(intent);
这是一个过程
详细如下:
总结起来就两部:
1,在AndroidMainfest.xml里面定义intent-filter
2,在函数里面使用,利用上面所说的语法
使用隐式Intent,我们不仅可以启动自己程序内的活动,还可以启动其他程序的活动,
这使得Android 多个应用程序之间的功能共享成为了可能。比如说你的应用程序中需要展示
一个网页,这时你没有必要自己去实现一个浏览器(事实上也不太可能),而是只需要调用
系统的浏览器来打开这个网页就行了。
比如说:
<activity android:name=".SecondActivity" > <intent-filter> <action android:name="com.example.activitytest.ACTION_START" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
在 标签中我们指明了当前活动可以响应com.example.activitytest.ACTION_START 这个action
然后是在设置listener里面进行相关操作:
语法为:
Intent intent = new Intent(“com.example.test.ACTION_START”);
startActivity(intent);
这是一个过程
详细如下:
button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent("com.example.activitytest.ACTION_START"); startActivity(intent); } });
总结起来就两部:
1,在AndroidMainfest.xml里面定义intent-filter
2,在函数里面使用,利用上面所说的语法
使用隐式Intent,我们不仅可以启动自己程序内的活动,还可以启动其他程序的活动,
这使得Android 多个应用程序之间的功能共享成为了可能。比如说你的应用程序中需要展示
一个网页,这时你没有必要自己去实现一个浏览器(事实上也不太可能),而是只需要调用
系统的浏览器来打开这个网页就行了。
相关文章推荐
- android中MVP模式(一)
- Android中用Drawable 自定义view的用法
- 【android】:android Debug心得
- 解决HierarchyViewer不能连接真机的问题
- ListView优化之一:重用convertView
- android4.4增加ethernet 文章 的补充内容
- 【android】:android之创建多个活动
- Android Studio中安装OpenCV SDK
- sdk版本对应的android版本
- 2015最流行的Android组件、工具、框架大全
- android 几种对话框的简单实现
- 【android】: something cannot be resolved to a type
- 得到一段字符串指定字符出现的数次
- AndroidMainfest.xml详解
- Android获取手机IP地址
- BitMap二次采样
- android view 原理 -- measure 分析与应用
- Android命令行播放MP3音乐
- android 修改图片的宽高
- Activity生命周期