Android未调用Looper.prepare()-Can't create handler inside thread that has not called Looper.prepare()

弹框没反应使用Looper解决_the caller should invoke Looper.prepare() and Looper.loop()---Android原生开发工作笔记239 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.AlertDialo... 阅读详情
 
Android 2.3.3       
Eclipse Version: 3.7.0       
LogCat 


LogCat 报错信息:

02-06 12:08:12.794: WARN/dalvikvm(503): threadid=18: thread exiting with uncaught exception (group=0x40015560)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): FATAL EXCEPTION: Thread-49
02-06 12:08:12.815: ERROR/AndroidRuntime(503): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at android.os.Handler.(Handler.java:121)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at android.app.Activity.(Activity.java:680)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at android.app.ListActivity.(ListActivity.java:175)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at android.preference.PreferenceActivity.(PreferenceActivity.java:76)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at com.taobao.nokia.manage.Preference.(Preference.java:62)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at com.taobao.nokia.List.run(List.java:297)
02-06 12:08:12.815: ERROR/AndroidRuntime(503): at java.lang.Thread.run(Thread.java:1019)
02-06 12:08:12.864: WARN/ActivityManager(61): Force finishing activity com.taobao.nokia/.Htc


发生错误原因:线程内未调用Looper.prepare(),不能创建处理器。
解决办法:在线程List的run()中加入 Looper.prepare();

public void run() {
	// TODO Auto-generated method stub
	super.run();
	Looper.prepare();
	setting = new Preference(context);
	}


 

Stata:手动安装ivreghdfe包的完整指南与常见问题解决 本文提供了Stata中手动安装ivreghdfe包的完整指南,包括准备工作、详细安装步骤及常见问题解决方案。ivreghdfe作为处理高维固定效应模型的强大工具,依赖ftools、reghdfe和ivreg2三个核心组件,手动安装可避免版本冲突问题。文章还分享了进阶使用技巧,如并行计算加速和保存固定效应估计值,助力用户高效完成工具变量回归分析。 阅读详情

相关推荐

jaka+realsense+aruco+手眼标定(python)

第二次重建了项目的手眼标定部分……有很多第一次记录遗漏的地方,在此补充。

drivenzyw的博客 2122

解决异常:Can't create handler inside thread that has not called Looper.prepare()

之前开发中遇到这个问题: java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare() 这个错误看字面意思也能理解,就是无法再没有looper的线程中创建handler 通常出现在我们在子线程中嵌套一个子线程的情况。因为子线程是相对于主线程而言的,不能生成子

后进生的代码笔记 2167

京瓷扫描驱动安装_京瓷喷头拆解和供墨原理剖析

在工业喷头打印领域,京瓷喷头作为主流喷头广泛应用于喷墨行业,目前京瓷喷头市面上销售主要有两个系列:KJ4A和KJ4B。其中KJ4A系列设计是用于油性墨水,例如UV墨水,主要用在广告领域;而KJ4B设计用于水性墨水,例如活性、分散墨水等,主要用在数码印花领域。最近我们团队对京瓷喷头进行了拆解分析,本期和大家分享一下我们对京瓷喷头拆解和喷头供墨原理的研究。京瓷喷头介绍1. KJ4A系列(油性)如下图所...

weixin_39883906的博客 1672

new Thread 时产生错误:Can't create handler inside thread that has not called Looper.prepare() 的解决方法

添加Looper.prepare();Looper.loop();         new Thread(new Runnable() {             @Override             public void run() {                 try {                     Thread.sleep(3000);

mecho的专栏 837

芯片设计中的复位艺术——从异步复位同步释放到复位树构建

本文深入探讨了芯片设计中复位策略的核心技术与工程实践。重点解析了异步复位同步释放这一黄金方案的原理与优势,它通过复位同步器解决了异步复位释放时的时序风险。文章进一步阐述了如何构建稳健的复位树以应对大规模SoC设计,并分析了多时钟域与低功耗场景下的复位设计挑战,为提升芯片可靠性提供了系统性的方法论。

neovim7hacker的博客 485

Mann-Kendall检验全解析:从原理到11种变体及Python实现

本文全面解析Mann-Kendall检验,从基础原理到应对自相关、季节性等复杂数据的11种关键变体,如Hamed-Rao修正、季节性MK和趋势自由预白化(TFPW)。详细阐述各方法的适用场景与数学原理,并提供完整的Python实战代码,帮助研究者针对不同数据特性选择最稳健的趋势分析方法。

weixin_29050271的博客 457

Android进程与线程基本知识

  本文介绍Android平台中进程与线程的基本知识。     很早的时候就想介绍一下Android中的进程和线程,但由于其他的事情一直给耽搁了,直到现在才能和大家一起分享下。     1.Android进程基本知识:   我们先来了解下Android中的进程基本知识。     当一个程序第一次启动的时候,Android会启动一个LINUX进程和一个主线程。默认的情况下,所有该程序的...

weixin_34413065的博客 206

LTE/NR中的相应cause场景【原创】

目录1.背景2.LTE EMM cause2.0 写在最前2.1 特殊处理的cause第一梯队第二梯队2.2 非特殊处理的cause3.NR cause 实网分析终端被拒等问题,经常遇到各类cause,其会对应不同的终端限制行为。查找已有资料后理解没有很深,自行总结本文用于梳理现象,如有错误敬请指正,转载请注明出处。 本文用于记录协议Ts 24.301及Ts 24.501中的cause及其对应行为。 已总结的cause值: 24.301中的cause分

2301_79567300的博客 3488

Can‘t create handler inside thread Thread*** that has not called Looper.prepare()

Android非UI主线程中,若干普通Java线程使用Handler发送接收消息线程1和线程2均为普通Java线程,在Android中创建,然后在这两个普通Java线程中使用Handler发送和接收消息。import android.os._java handler 非主线程。做一个简单的关于Handler,Looper,Message的小演示,代码主界面一个Button按钮,点击发送消息(累计)给线程的Looper循环,然后在LogCat中打印出来:package zhangphil.looper;

Zhang Phil 2683

WPS访问权限不足怎么解决??具体怎么操作?

🏆本文收录于 《全栈 Bug 调优(实战版)》 专栏。专栏聚焦真实项目中的各类疑难 Bug,从成因剖析 → 排查路径 → 解决方案 → 预防优化全链路拆解,形成一套可复用、可沉淀的实战知识体系。无论你是初入职场的开发者,还是负责复杂项目的资深工程师,都可以在这里构建一套属于自己的「问题诊断与性能调优」方法论,助你稳步进阶、放大技术价值。

**My Coding Family** 4169

Agent应用实践之三 - 基础:AgentScope-ReActAgent源码解析

本章通过总结AgentScope的核心类,再通过分析ReActAgent调用大模型的底层源码原理。使我们基本了解了Agent的基本原理,这个实现方式与OpenClaw使用pi-mono的Agent基础框架是一致的。了解完ReActAgent的基本原理,下一章我们会将一下SpringBoot集成方式的代码原理,这两章是我们构建后续内容的基本框架。

代码让AI扣 467

Can't create handler inside thread that has not called Looper.prepare()

Looper.prepare(); // Can't create handler inside thread that has not called Looper.prepare()。 Toast.makeText(context,"登录超时",Toast.LENGTH_SHORT).show(); ...

Choi晨的博客 924

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Android进阶 十六 子线程调用Toast报Can't create handler inside thread t

Android进阶 十六 子线程调用Toast报Can't create handler inside thread t

qq_43667184的博客 177

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Android未调用Looper.prepare()-Can't create handler inside thread that has not called Looper.prepare()...

Android 2.3.3 Eclipse Version: 3.7.0 LogCat LogCat 报错信息: 02-06 12:08:12.794: WARN/dalvikvm(503): threadid=18: thread exiting with uncaught exception (group=0x40015560) 02-06 12:08:...

helpbs 117

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Android "Can't create handler inside thread that has not called Looper.prepare()" 问题

创建了一个线程,并且在线程里面执行异步处理,如下: new Handler().postDelayed(new Runnable() { @Override public void run() { // do something } }, 100); 执行的时候...

DM专栏 441

【Android】报错:Can't create handler inside thread that has not called Looper.prepare()

在项目一个回调接口里使用 new Handler() 时出现报错: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() new Handler(Looper.getMainLooper()).post(new Runnable() { @Ove...

DawnYu 5125

Can't create handler inside thread that has not called Looper.prepare()解决办法

private Handler mHandler = new Handler(){ public void handleMessage(Message msg) { switch (msg.what) { case ID_USER:

a7a9a68的专栏 6万+

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

在Android中不允许Activity里新启动的线程访问该Activity里的UI组件,这样会导致新启动的线程无法改变UI组件的属性值。 出现java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()异常 然而,我们实际需要,在很多时候都需要异步获取数据

wsyjx22的专栏 3527

报错“Can't create handler inside thread that has not called Looper.prepare()” 的处理方法

如果在编译的时候出现这样的报错:Can't create handler inside thread that has not called Looper.prepare(),是因为新new的线程中出错,线程中没有消息处理机制,无法进行消息处理。     解决方法:在线程中报错的地方,在报错方法的前面加上Looper.prepare();在后面加上Looper.loop();之后再编译运行就不会

极客时代 2647

子线程调用Toast报Can't create handler inside thread that has not called Looper.prepare() 错误

原文章链接:http://hi.baidu.com/_guangren_/item/8e61f31cecad9a701009b5b7 感谢原作者智慧。 我今天是在子线程中调用AlertDialog的时候报的Can't create handler inside thread that has not called Looper.prepare() ,在前后加Looper.prepare();和

crxmai的专栏 1038

Toast报Can't create handler inside thread that has not called Looper.prepare() 错误

错误 使用子线程调用Toast报Can’t create handler inside thread that has not calledLooper.prepare()错误。 原因 toast的实现需要在activity的主线程才能正常工作,传统的非主线程不能使toast显示在actvity上,只能通过Handler可以使自定义线程运行于Ui主线程。 解决方法 Looper.prepare()...

柚子君的小窝 3508

Can't create handler inside thread that has not called Looper.prepare()问题解决

UI的显示要在UI线程中执行,而不能在子线程中,也不能在异步线程中执行。

记录和分享程序人生的点点滴滴 2万+

错误解决 Can't create handler inside thread that has not called Looper.prepare()

错误Can't create handler inside thread that has not called Looper.prepare()的解决方法 Android不能在线程里面更新UI

qq_31680503的博客 824
上一篇: 不能创建处理器 Can't create handler inside thread that has not called Looper.prepare()
下一篇: layout使用继承TextView,Activity未使用,报java.lang.NullPointerException一例
DebugLog
博客等级 码龄15年 10粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值