Android 剖面

Android 剖面

Parcel

Android中Parcel的分析以及使用

ANR

app主线程输入事件/特定操作处于阻塞状态的时间过长,会触发“应用无响应”(ANR) 错误。如果应用位于前台,系统会向用户显示一个对话框

  • 输入事件超时时间5s
  • 前台/后台 BroadcastRecevier#onReceive 超时时间10s/60s
  • 前台/后台服务超时20s/200s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ActivityManagerService.java
// How long we wait until we timeout on key dispatching.
static final int KEY_DISPATCHING_TIMEOUT = 5*1000;
// How long we allow a receiver to run before giving up on it.
static final int BROADCAST_FG_TIMEOUT = 10*1000;
static final int BROADCAST_BG_TIMEOUT = 60*1000;
ActivityTaskManagerService.java
public static final int KEY_DISPATCHING_TIMEOUT_MS = 5 * 1000;

ActiveServices.java
// How long we wait for a service to finish executing.
static final int SERVICE_TIMEOUT = 20*1000;

// How long we wait for a service to finish executing.
static final int SERVICE_BACKGROUND_TIMEOUT = SERVICE_TIMEOUT * 10;
0%