当前位置:  编程技术>移动开发
本页文章导读:
    ▪小弟我对Activity Lifecycle的理解        我对Activity Lifecycle的理解 本文部分来自android->developer->dev guide->Application Fundamentals第一部分 activity stackActivities in the system are managed as an activity stack. When a new activity is started, it is placed on t.........
    ▪ 小弟我对Service Lifecycle的理解        我对Service Lifecycle的理解 本文部分来自android->developer->dev guide->Application Fundamentals摘自Class OverviewA Service is an application component representing either an application's desire to perform a longer-running operat.........
    ▪ ipad着手小记       ipad入手小记       入手iPad一周多了,写点感受.先说购买的心得,由于iPad较大,最好考虑一下贴膜和外套,全皮的外套像一本书一样,外出拿着十分方便,但是太过厚重,自己使用的话建议还是胶套.........

[1]小弟我对Activity Lifecycle的理解
    来源: 互联网  发布时间: 2014-02-18
我对Activity Lifecycle的理解
本文部分来自android->developer->dev guide->Application Fundamentals

  • 第一部分 activity stack

Activities in the system are managed as an activity stack. When a new activity is started, it is placed on the top of the stack and becomes the running activity -- the previous activity always remains below it in the stack, and will not come to the foreground again until the new activity exits.

注释:重点理解,Activity是被一个activity stack管理的。

  • 第二部分 essentially three states

An activity has essentially three states:

    * It is active or running when it is in the foreground of the screen (at the top of the activity stack for the current task). This is the activity that is the focus for the user's actions.
    * It is paused if it has lost focus but is still visible to the user. That is, another activity lies on top of it and that activity either is transparent or doesn't cover the full screen, so some of the paused activity can show through. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations.
    * It is stopped if it is completely obscured by another activity. It still retains all state and member information. However, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.

注释:重点理解,activity 的三个重要的状态:active or running, paused, stopped.

  • 第三部分 three nested loops

There are three nested loops about activity.

    * The entire lifetime of an activity happens between the first call to onCreate() through to a single final call to onDestroy(). An activity does all its initial setup of "global" state in onCreate(), and releases all remaining resources in onDestroy(). For example, if it has a thread running in the background to download data from the network, it may create that thread in onCreate() and then stop the thread in onDestroy().
    * The visible lifetime of an activity happens between a call to onStart() until a corresponding call to onStop(). During this time, the user can see the activity on-screen, though it may not be in the foreground and interacting with the user. Between these two methods, you can maintain resources that are needed to show the activity to the user. For example, you can register a BroadcastReceiver in onStart() to monitor for changes that impact your UI, and unregister it in onStop() when the user can no longer see what you are displaying. The onStart() and onStop() methods can be called multiple times, as the activity alternates between being visible and hidden to the user.
    * The foreground lifetime of an activity happens between a call to onResume() until a corresponding call to onPause(). During this time, the activity is in front of all other activities on screen and is interacting with the user. An activity can frequently transition between the resumed and paused states — for example, onPause() is called when the device goes to sleep or when a new activity is started, onResume() is called when an activity result or a new intent is delivered. Therefore, the code in these two methods should be fairly lightweight.

注释:
entire lifetime, 从onCreate()->onDestroy(),例子,thread后台下载数据;
visible lifetime,从onStart()->onStop(),例子,可见的状态,虽然不与前台用户互动;
foreground lifetime,从onResume()->onPause(),例子,在activity运行期间,被一个新的activity打断.

  • 第四部分 diagram illustrates

有了以上的理解,对于activity生命周期的图来说,自然而然就熟记忆了。



    
[2] 小弟我对Service Lifecycle的理解
    来源: 互联网  发布时间: 2014-02-18
我对Service Lifecycle的理解
本文部分来自android->developer->dev guide->Application Fundamentals

  • 摘自Class Overview

A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding <service> declaration in its package's AndroidManifest.xml. Services can be started with Context.startService() and Context.bindService().

  • 两种启动service的方法:

Using a service in two ways
Context.startService() and Context.bindService(),这两种方法实现不同的接口。
startService()生命周期调用的方法
    void onCreate()
    void onStart(Intent intent)
    void onDestroy()
bindService()生命周期调用的方法
    void onCreate()
    IBinder onBind(Intent intent)
    boolean onUnbind(Intent intent)
    void onRebind(Intent intent)
    void onDestroy()


  • two nested loops of the service's lifecycle

By implementing these methods, you can monitor two nested loops of the service's lifecycle:
    * The entire lifetime of a service happens between the time onCreate() is called and the time onDestroy() returns. Like an activity, a service does its initial setup in onCreate(), and releases all remaining resources in onDestroy(). For example, a music playback service could create the thread where the music will be played in onCreate(), and then stop the thread in onDestroy().
    * The active lifetime of a service begins with a call to onStart(). This method is handed the Intent object that was passed to startService(). The music service would open the Intent to discover which music to play, and begin the playback.
      There's no equivalent callback for when the service stops — no onStop() method.

  • diagram illustrates




    
[3] ipad着手小记
    来源: 互联网  发布时间: 2014-02-18
ipad入手小记

 

    入手iPad一周多了,写点感受.先说购买的心得,由于iPad较大,最好考虑一下贴膜和外套,全皮的外套像一本书一样,外出拿着十分方便,但是太过厚重,自己使用的话建议还是胶套或者苹果那种较薄的布套,所以购买时还需要多一些预算(两三百),容量上自己用的话16G有点太少.

    刚入手时觉得有点后悔,5k多的价格买来只能上上网,感觉不太值,忍了不到一个星期,就把原生421版的不完美越狱了,其实越狱的过程很快也很简单,一次性过,redsnow制作的也相当傻瓜化,英文程度较好的人不用看教程直接都可以用了,新手倒是要注意学习先备份shsh,然后放心大胆的折腾实在不行也就恢复成出厂状态而已.不完美越狱关机后重启必须用redsnow引导,据说不引导也可以进入,但是非正版程序打不开.不过我得机子没有重开过,其实影响不大.ipad的电池还算好,连续用10小时可能有点夸张,但是用的频繁一般两天一充没有问题,iphone的话基本上半天就没电了.

    越狱后果然是焕然一新的感觉,以前说过,没越狱的iphone就是褪了毛的凤凰不如鸡,简直就是拿了手机当砖头用,还不如不买,当然购买正版的除外,看到有的人买了iphone就是装几个免费的软件和打电话,实在是感慨啊.给女儿装了一堆读书教育的软件,自己使用的话感觉主要有两个上网和看书,用iPad上网还是相当方便的,基本上在家我都不开电脑了.iPad用来看漫画其实是相当棒的,不过对于16开的香港漫画而言还是有点小,应该说是9寸的遗憾.ipad上的软件和游戏相对还是较少,不少好玩的游戏还没有ipad版,特别是新游戏,尤其是UCWeb居然也没有ipad版,不得不说是相当大的遗憾.大的游戏基本上没时间玩.

    说一下ipad的缺点:

1 3g版居然只能用联通的卡,不支持gsm,估计ipad2可能会有所改进

2 尺寸略小,不适合看16开的书

3 不能在一般的电脑usb上充电,只能用充电器,而且充电时间较长,不过我试过macbook确实是可以的,奇怪的是启动macbook上的xp就无法充电了,难道mac系统对usb还有增高电压的作用?

4 性能略低,用safari上网的时候可以感觉到,打开页面列表时响应有点迟缓,甚至有些跳跃,UCWeb反而没太大的感觉,不知道是不是软件的问题,但是不要指望它的性能超越笔记本就是了.

5 对iphone的程序支持还不是很好,一些在iphone上正常的程序在ipad上会退出.

6 支持3g,却不能打电话,不能不说老乔真是少跟筋

7 其实也不算缺点,就是ipad的程序普遍太大了,下载软件比较痛苦,如果你同时有iphone和ipad,对你的硬盘空间也是一个考验,至于直接在ipad上下载软件,还是省省吧.

8 后台运行,很多时候我们需要程序在后台下载,自己处理其它的事情,甚至在锁频的情况下也能自己下载,不过遗憾的是,现在还不行,如果需要下载东西,我不得不接上电源,并且保持下载的软件打开.


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android提高之多方向抽屉实现方法 iis7站长之家
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3