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
        }
    }
}
相关推荐
mygljx1 天前
MySQL 数据库连接池爆满问题排查与解决
android·数据库·mysql
xinhuanjieyi1 天前
ruoyimate导入sql\antflow\bpm_init_db.sql报错
android·数据库·sql
闲猫1 天前
基于RABC的权限控制设计
android
星霜笔记1 天前
GitMob — 手机端 GitHub 管理工具
android·kotlin·github·android jetpack
LiuYaoheng1 天前
问题记录:Android Studio Low memory
android·ide·android studio
独隅1 天前
Python 标准库 (Standard Library) 全面使用指南
android·开发语言·python
always_TT1 天前
strlen、strcpy、strcat等常用字符串函数
android
qqty12171 天前
MySQL Workbench菜单汉化为中文
android·数据库·mysql
2401_895521341 天前
MySQL中between and的基本用法
android·数据库·mysql
云云鬼才1 天前
CoCo编辑器、图形化编程怎么调用Scheme(跳转应用)
android