Android学习 Components
来源:互联网 发布:淘宝生意参谋数据异常 编辑:程序博客网 时间:2024/04/25 22:22
App Components:
Activity 后台与前台ui layout交互
Service 在后台,无ui layout
broadcast receiver 广播接收器 监听组件
content provider 内容提供器,不同app之间的数据交互
注意:Intent 实际上不是组件,用来封装app内的组件即Activity , Service , BroadCast Receiver
1.Intent 与Intent Filter
Intent 实际上不是组件,用来封装app内的组件即Activity , Service , BroadCast Receiver。
显示Intent:明确指定触发或启动的组件
隐式Intent:需要指定触发或启动的组件应满足怎样的条件,被调用组件通过IntentFilter申明自己所满足的条件,说明自己能处理哪些隐式Intent
2.Activity
生命周期:
public class ExampleActivity extends Activity { @Override public void注意:onCreate
(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The activity is being created. } @Override protected voidonStart()
{ super.onStart(); // The activity is about to become visible. } @Override protected voidonResume()
{ super.onResume(); // The activity has become visible (it is now "resumed"). } @Override protected voidonPause()
{ super.onPause(); // Another activity is taking focus (this activity is about to be "paused"). } @Override protected voidonStop()
{ super.onStop(); // The activity is no longer visible (it is now "stopped") } @Override protected voidonDestroy()
{ super.onDestroy(); // The activity is about to be destroyed. }}
把Activcity想成 录音机播放录音带的过程
1.onCreate录音带放进录音机
2.onStart开始播放录音带
3.onResume 继续播放
4.onPause 暂停播放(Activity 相关页面可见)
5.onStop 停止播放,但录音带还在录音机里(Activity还在内存里,但页面不可见)
6.onDestroy 录音带拿出来(Activity 不在内存里了)
在一个activity里start另一个activity,两个activity都经历生命周期,如在A里开启B
1.A 会onPause
2.B onCreate onStart onResume(B 获得焦点)
3.如果A不再需要可见,则A onStop
3.Fragment(看做一个Activity的子Activity)
Fragment为一个Activity的一部分的用户界面,可在一个Activity中有多个Fragment组成多界面,Fragments有自己的生命周期,在该个Activity中可以添加或移除Fragment.
注意:Fragment作为子Activity,因此一定要被嵌入一个Activity, Fragment的生命周期会直接影响到host Activitu的生命周期。
使用Fragment例子:
用处:适应不同的屏幕尺寸
新闻app,屏幕左边为新闻标题列表,屏幕右边为一条新闻内容,新闻标题与新闻内容是在一个activity,在一个屏幕上,不需要跳转页面,(否则不是标题一个activity,内容一个activity需要跳转页面)
app底层菜单栏,屏幕下边为选项,屏幕上边为选项的内容
- Android学习 Components
- Android 4 components
- Android - Custom Components
- Android Architecture Components
- 浅谈Android Architecture Components
- 【译】Android Architecture Components
- Android Architecture Components(1)
- Android Architecture Components(2)
- Android Architecture Components(3)
- 谷歌官方Android应用架构库(Android Architecture Components)学习完整版
- jbpm5学习资料(组件Components)
- jbpm5学习资料(组件Components)
- jBPM Components(jbpm5学习资料)
- jBPM Components(jbpm5学习资料)
- Android API Guides - App Components
- Android 开发之 App Components
- Android API Guides---Custom Components
- Android Architecture Components+MVP 实战
- win7和win8下命令行输入安装工具命令时提示OpenSCManager failed解决办法
- file.separator的用法含义
- 轮播 绝对定位 在同一位置
- CFCA 数字证书的安装与使用
- Cocos2d-x 序列帧动画
- Android学习 Components
- Android 程序资源
- USB子系统一之 USB接口技术发展历史和接口技术的优点
- iOS App开发那些事:如何选择合适的人、规范和框架?
- html5 canvas 实现刮奖效果
- android学习五---OpenCV for android环境搭建
- html文本显示默认值的事件
- android activity的状态保存机制
- centos挂载硬盘、分区、删除