Android Development Notes-4(BroadcastReceiver, Manifests)

Summary: BroadcastReceiver, Manifests, Delvik VM, Zigote, Life Cycle, apk

-A broadcast receiver receives the action of  Intent objects, similarly to an  Activity , but does not have its own user interface

-A typical use for a broadcast receiver might be to receive an alarm that causes an app to become active at a particular time

-Android requires applications to explicitly describe their contents in an XML file called AndroidManifest.xml

-Activity ,  Service , ContentProvider , and  BroadcastReceiver provide the foundation of Android application development . To make use of any of them, an application must include corresponding declarations in its AndroidManifest.xml file.



AndroidManifest.xml sample:


res/
layout/
... contains application layout files ...
drawable/
...contains images, patches, drawable xml ...
raw/
... contains data files that can be loaded as streams ...
values/
... contains xml files that contain string, number values used in code ...
src/
java/package/directories/

-Android executes multiple instances of the Dalvik VM, one for each task

-Android must efficiently divide memory into multiple heaps. Each heap should be relatively small so that many applications can fit in memory at the same time. 

-Android’s approach to multiprocessing, using multiple processes and multiple instances of a VM, requires that each instance of the VM be space-efficient. This is achieved
partly through the component life cycle, which enables objects to be garbage-collected and recreated, and partly by the VM itself.

-Zygote. It is an instance of the Dalvik VM that contains a set of preloaded classes for enhancement of performance.

-The most complex component life cycle is the activity life cycle. Here we will diagram it and take a look at how these state transitions are handled in code


-Sample code:

@Override
protected void onSaveInstanceState(Bundle outState) {
// Save instance-specific state
outState.putString("answer", state);
super.onSaveInstanceState(outState);
Log.i(TAG, "onSaveInstanceState");
}
@Override
protected void onRestoreInstanceState(Bundle savedState) {
super.onRestoreInstanceState(savedState);
// Restore state; we know savedState is not null
String answer = savedState.getString("answer");
// ...
Log.i(TAG, "onRestoreInstanceState"
+ (null == savedState ? "" : RESTORE) + " " + answer);
}
-In a lot of Android code, especially in small examples, very few life cycle callbacks are implemented. That is because the  Activity parent class handles life cycle callbacks
-Android provides an application called  apkbuilder for generating installable Android application files, which have the extension .apk. An .apk file is in ZIP file format

Author:Joey_Zhang

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值