弹框没反应使用Looper解决_the caller should invoke Looper.prepare() and Looper.loop()---Android原生开发工作笔记239

当遇到错误提示'The caller should invoke Looper.prepare() and Looper.loop()'时,意味着消息循环被阻塞导致对话框无法正常弹出。解决方法是在单独的线程中使用Looper.prepare()和Looper.loop()成对出现,确保每个线程只有一个Looper对象。避免在Activity中直接使用,以防限制其他Looper的创建。同时提到了技术交流群和优快云账号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

            E/Handler: This is not main thread, and the caller should invoke Looper.prepare()  and Looper.loop()called byandroid.os.Handler.<init>:122 android.app.Dialog.<init>:156 android.app.AlertDialog.<init>:205 android.app.AlertDialog$Builder.create:1112 com.baidu.idl.main.facesdk.utils.PromptDialog.showConfirm:142 com.baidu.idl.main.facesdk.activity.gate.FaceBodyCheckActivity$23.onResponse:2262 okhttp3.RealCall$AsyncCall.execute:126 okhttp3.internal.NamedRunnable.run:32 
            上面这个错误:


是因为消息循环阻塞引起的:会导致的现象是,比如某个消息框,本来应该弹出来,但是消息处理阻塞了,没有弹出来

等:

用法:下面这样用,要注意:Looper.prepare(); 和Looper.loop() 是成对出现的.并且一定要注意,一个线程中,只能有一对,Looper.prepare(),Looper.loop()
Looper对象,一

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

添柴程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值