AMS:ActivityRecord 理解

将 ActivityRecord 比作人的出行记录,从源码中分析 ActivityRecord 记录的信息类型,对其进行了理解性探究。
摘要由CSDN通过智能技术生成

什么是 ActivityRecord ?android 的解释是 An entry in the history task, representing an activity。大意是 ActivityRecord 是历史任务中的一个记录,代表着 activity,换言之,它是应用层的 activity 在 AMS 中的记录。

那么这个记录,也就是 ActivityRecord 需要记录哪些东西呢 ?

1、Activity 稳定不变的身份信息

这类信息是每个 Activity 出生就确定的,且不会改变,标识着一个 activity 的身份。就好比人的出生信息。这些信息有 info、packageName、icon 等

 		 final ActivityInfo info; // activity info provided by developer in AndroidManifest
439      // The package implementing intent's component
440      // TODO: rename to mPackageName
441      final String packageName;
442      // the intent component, or target of an alias.
443      final ComponentName mActivityComponent;
		 private int icon;               // resource identifier of activity's icon.

2、Activity 启动时基本信息

是指启动 Activity 时,才确定的信息,在每次启动时可能会不同。如 launchedFromPid、task、launchedFromPackage、processName。

这样说还是挺抽象的,如果把启动 activity 比作人进行一次外出的话,这类信息就是出发地、目的地、出行方式,在计划这次出行后才能确定。

		 final int launchedFromPid; // always the pid who started the activity.
449      final String launchedFromPackage; // always the package who started the activity.
455      final String processName; // process where this component wants to run
469      private Task task;              // the task this is in.

3、Activity 过程耗时信息

在 activity 启动过程中,一些阶段的耗时信息。这类信息是只有阶段完成后才能统计确定。

470      private long createTime = System.currentTimeMillis();
471      long lastVisibleTime;         // last time this activity became visible
472      long pauseTime;               // last time we started pausing the activity
473      long launchTickTime;          // base time for launch tick messages
474      long topResumedStateLossTime; // last time we reported top resumed state loss to an activity

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值