Handler系列-prepareMainLooper在哪里调用的

ActivityThread的main方法里调用prepareMainLooper

java 复制代码
public final class ActivityThread {
    public static void main(String[] args) {
        Looper.prepareMainLooper(); //创建sMainLooper

        Looper.loop();
    }
}

prepareMainLooper创建了sMainLooper

java 复制代码
public final class Looper {
    private static Looper sMainLooper;  // guarded by Looper.class

    public static void prepareMainLooper() {
        prepare(false); //创建Looper
        synchronized (Looper.class) {
            if (sMainLooper != null) {
                throw new IllegalStateException("The main Looper has already been prepared.");
            }
            sMainLooper = myLooper(); //赋值给sMainLooper
        }
    }
}
相关推荐
liang_jy4 小时前
Android 窗口容器树(一)—— 窗口和窗口容器树
android·源码
HUGu RGIN4 小时前
MySQL--》如何在MySQL中打造高效优化索引
android·mysql·adb
Joseph Cooper7 小时前
Linux/Android 跟踪技术:ftrace、TRACE_EVENT、atrace、systrace 与 perfetto 入门
android·linux·运维
空中海7 小时前
安卓逆向03. 动态调试、抓包分析与 Frida Hook
android
一起搞IT吧8 小时前
相机Camera日志实例分析之二十:相机Camx【照片后置4800/5000/6400万拍照】单帧流程日志详解
android·嵌入式硬件·数码相机·智能手机
jinanwuhuaguo9 小时前
(第三十三篇)五月的文明奠基:OpenClaw 2026.5.2版本的文明级解读
android·java·开发语言·人工智能·github·拓扑学·openclaw
千码君201611 小时前
Trae:一些关于flutter和 go前后端开发构建的分享
android·flutter·gradle·android-studio·trae·vibe code
重生之我是Java开发战士14 小时前
【MySQL】事务 & 用户与权限管理
android·数据库·mysql
怣疯knight16 小时前
Windows不安装 Android Studio如何打包安卓软件
android·windows·android studio
ke_csdn16 小时前
从Java演变到Kotlin下的jet pack
android