使用ClipboardManager碰到Can't create handler inside thread that has not called Looper.prepare()

直接放上我的代码,希望能给碰到同样问题的朋友提供帮助

	    Runnable runnable = new Runnable() {
	        public void run() {
			   ClipboardManager clipboard =  (ClipboardManager)GameUtil.getIntance().getContext().getSystemService(Context.CLIPBOARD_SERVICE);
	           clipboard.setText(content);
	        }
		};
		GameUtil.getIntance().getGameActiviti().runOnUiThread(runnable);

使用ClipboardManager碰到Can't create handler inside thread that has not called Looper.prepare(),布布扣,bubuko.com

使用ClipboardManager碰到Can't create handler inside thread that has not called Looper.prepare()

时间: 2024-10-25 18:26:36

使用ClipboardManager碰到Can't create handler inside thread that has not called Looper.prepare()的相关文章

使用ClipboardManager碰到Can't create handler inside thread that has not called Looper.prepare()

直接放上我的代码.希望能给碰到相同问题的朋友提供帮助 Runnable runnable = new Runnable() { public void run() { ClipboardManager clipboard = (ClipboardManager)GameUtil.getIntance().getContext().getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(content); } }; GameUt

Android蓝牙开发,报BluetoothAdapter﹕ Can't create handler inside thread that has not called Looper.prepare

这个错误翻译的意思是:不能在没有Looper.prepare的线程里面创建handler. 起初我很疑惑,我根本没有用到工作线程,也没有创建handler.报错的代码如下: // Device scan callback. private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final Blu

Android 线程更新UI报错 : Can't create handler inside thread that has not called Looper.prepare()

MainActivity中有一个按钮,绑定了save方法 public void save(View view) { String title = titleText.getText().toString(); String timelength = lengthText.getText().toString(); ExecutorService exec = Executors.newCachedThreadPool(); exec.execute(new NewsService(getApp

关于子线程使用Toast报错Can't create handler inside thread that has not called Looper.prepare()的解决办法

形同如下代码,在Thread中调用Toast显示错误信息: new Thread(new Runnable(){ @Override public void run() { try{ weatherData = getWeatherData(strUrl); parseJson(weatherData); }catch(Exception e){ Toast.makeText(WindowApplication.getAppContext(), e.toString(), Toast.LENGT

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

又报错了,不过早也习以为常了. Can't create handler inside thread that has not called Looper.prepare() 我把文档给摘录下来了,大家可以看看. 这个类被用于为线程运行消息循环.默认线程并没有消息循环与之关联,所以你需要创建一个,在线程中调用prepare()以运行这个循环,然后调用loop()在循环结束时获取进程信息. 和消息循环交互最多的就是通过Handler类. 下面是一个实现了Looper线程的典型实例,通过分离的pre

Android handler 报错处理Can't create handler inside thread that has not called Looper.prepare()

解决方法,在ui线程里面创建handler m_MainActivity.runOnUiThread(new Runnable(){ @Override public void run() { // TODO Auto-generated method stub GameBoxUtil.startPay(m_MainActivity,String.valueOf(amount), productName, payCode,orderId,payHandler); }}); Android han

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

最近做项目时出现个问题. 在一个基类中,创建一个Handler对象用于主线程向子线程发送数据,代码如下: this.mThirdHandler = new Handler(){ @Override public void handleMessage(android.os.Message msg) { super.handleMessage(msg); Bundle bundle = msg.getData(); isStop = bundle.getBoolean(mContext.getTex

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

我在自定义ContentProvider中,遇到了这个错误: 原因在于: 我在要分享数据的程序中创建数据库的弹出了一个土司,这个土司在主线程中,在第二个程序中,向数据库中添加数据的时候导致其挂了. 切记:不要在主线程中更新UI. 错误BUG解决:Can't create handler inside thread that has not called Looper.prepare()

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

E/AndroidRuntime(7200): Uncaught handler: thread Thread-8 exiting due to uncaught exceptionE/AndroidRuntime( 7200): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 原因是非主线程中默认没有创建Looper对象,需要先调用Looper