Android Develop API 1

任何资料在官方文档面前都逊色啊。算是中文的总结吧,对Android Develop API 可以对着看,大家交换下意见,错误请务必指正。 
Android应用
  • .Android是基于Linux内核的多用户操作系统,默认会给每一个应用分配唯一的User ID,并为该应用所有的文件赋予基于此User ID的访问限制(应该是沿用linux自身基于用户的权限管理实现)
  • Android应用以独立的linux进程执行,拥有自己的虚拟机。
  • 不同的应用可以共用一个User Id,相互共享文件或者是共用进程和虚拟机(使用相同证书的情况下)--没实践过
  • 应用安装时必须让用户赋予访问资源的权限,比如相机,通讯录。
Android组件
Activity
用户界面 
Service
后台服务
Content provider
应用共享数据 
Broadcast receivers
系统级别广播
 
  AndroidManifest.xml位于应用根目录
声明应用组件
声明应用依赖
声明组件功能
 
Activity

Table 1. A summary of the activity lifecycle's callback methods.

Method Description Killable after? Next
onCreate() Called when the activity is first created. This is where you should do all of your normal static set up — create views, bind data to lists, and so on. This method is passed a Bundle object containing the activity's previous state, if that state was captured (see Saving Activity State, later).

Always followed by onStart().

No onStart()
  onRestart() Called after the activity has been stopped, just prior to it being started again.

Always followed by onStart()

No onStart()
onStart() Called just before the activity becomes visible to the user.

Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.

No onResume() 
or
onStop()
  onResume() Called just before the activity starts interacting with the user. At this point the activity is at the top of the activity stack, with user input going to it.

Always followed by onPause().

No onPause()
onPause() Called when the system is about to start resuming another activity. This method is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns.

Followed either by onResume() if the activity returns back to the front, or by onStop() if it becomes invisible to the user.

Yes onResume() 
or
onStop()
onStop() Called when the activity is no longer visible to the user. This may happen because it is being destroyed, or because another activity (either an existing one or a new one) has been resumed and is covering it.

Followed either by onRestart() if the activity is coming back to interact with the user, or byonDestroy() if this activity is going away.

Yes onRestart()
or
onDestroy()
onDestroy() Called before the activity is destroyed. This is the final call that the activity will receive. It could be called either because the activity is finishing (someone called finish() on it), or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method. Yes nothing
 
ActivityA 启动ActivtyB时,两个activty都经历状态转换,当A与B需要数据交互需要注意调用时序列。
ActivityA.onPause() ->ActivityB.onCreate()-> ActivityB.onStart()->ActivityB.onResume->ActivityA.onStop()
系统将会保存stop的activity至堆栈,Back Button按下之后会弹出上一个Activty。
当activity的手机方向改变时系统会destroy并create。这时onRestoreInstanceSate()跟onStoreInstanceState()方法就会被调用,默认实现是保存当前的view状态,如果希望不同手机方向有不同的布局,需要自己保存View的状态。
android系统通过intent在不同组件之间相互调用。
android允许activityA启动其他应用的activtyB(通过进程间通信的binder机制),但是是通过向系统发布intent调用消息来实现的,activtyB运行在B进程,通过intent返回数据。

猜你喜欢

转载自zhangbinone.iteye.com/blog/1856268
今日推荐