• 代理原有的Handler.Callback,感知Application onCreate的结束时间


    public class HackCallback implements Handler.Callback {
    private static final String TAG = "Matrix.HackCallback";
    private static final int LAUNCH_ACTIVITY = 100;
    private static final int ENTER_ANIMATION_COMPLETE = 149;
    private static final int CREATE_SERVICE = 114;
    private static final int RECEIVER = 113;
    private static boolean isCreated = false;

    private final Handler.Callback mOriginalCallback;

    public HackCallback(Handler.Callback callback) {
    this.mOriginalCallback = callback;
    }

    @Override
    public boolean handleMessage(Message msg) {
    // MatrixLog.i(TAG, "[handleMessage] msg.what:%s begin:%s", msg.what, System.currentTimeMillis());
    if (msg.what == LAUNCH_ACTIVITY) {
    Hacker.isEnterAnimationComplete = false;
    } else if (msg.what == ENTER_ANIMATION_COMPLETE) {
    Hacker.isEnterAnimationComplete = true;
    }
    if (!isCreated) {
    if (msg.what == LAUNCH_ACTIVITY || msg.what == CREATE_SERVICE || msg.what == RECEIVER) {
    //发送启动Activity等消息,认为是Application onCreate的结束时间
    Hacker.sApplicationCreateEndTime = System.currentTimeMillis();
    Hacker.sApplicationCreateEndMethodIndex = MethodBeat.getCurIndex();
    Hacker.sApplicationCreateScene = msg.what;
    isCreated = true;
    }
    }
    if (null == mOriginalCallback) {
    return false;
    }
    return mOriginalCallback.handleMessage(msg);
    }

  • 相关阅读:
    动态规划突破
    日志如何进行处理
    多线程相关问题
    Activity工作流框架
    修改模块
    spring多模块搭建Eureka服务器端
    springcould多模块搭建Eureka的服务器端口
    java操作elecsearch
    在elementui和MyBatis中前后端分离中使用shiro
    elementui的和前后端分离的微信登陆功能
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11295905.html
Copyright © 2020-2023  润新知