记录第一个Activity的onCreate时间

@Override
public void onActivityCreated(Activity activity) {
super.onActivityCreated(activity);
if (isFirstActivityCreate && mFirstActivityMap.isEmpty()) {
String activityName = activity.getComponentName().getClassName();
mFirstActivityIndex = getMethodBeat().getCurIndex();
mFirstActivityName = activityName;
mFirstActivityMap.put(activityName, System.currentTimeMillis());
MatrixLog.i(TAG, "[onActivityCreated] first activity:%s index:%s", mFirstActivityName, mFirstActivityIndex);
getMethodBeat().lockBuffer(true);
}
}
复制代码
记录Activity获取焦点的时间(在编译期,在Activity子类的onWindowFocusChange方法中插入MethodBeat.at方法)

public static void at(Activity activity, boolean isFocus) {
MatrixLog.i(TAG, "[AT] activity: %s, isCreated: %b sListener size: %d,isFocus: %b",
activity.getClass(http://www.amjmh.com/v/BIBRGZ_558768/).getSimpleName(), isCreated, sListeners.size(), isFocus);
if (isCreated && Thread.currentThread() == sMainThread) {
for (IMethodBeatListener listener : sListeners) {
listener.onActivityEntered(activity, isFocus, sIndex - 1, sBuffer);
}
}
}
复制代码
当Activity获取到焦点时,认为启动阶段结束(若有SplashActivity,则记录下一个Activity获取焦点的时间)

@Override
public void onActivityEntered(Activity activity, boolean isFocus, int nowIndex, long[] buffer) {
...启动数据分析
}

posted @ 2019-08-03 19:11  水至清明  阅读(192)  评论(0编辑  收藏  举报