gistfile1.txt //因调用getSystemService()方法引发报错://Can't create handler inside thread that has not called Looper.prepare()//使用Runnable()开辟线程调用//final关键字可以将paramStr设为方法内共有参数public
//因调用getSystemService()方法引发报错: //Can't create handler inside thread that has not called Looper.prepare() //使用Runnable()开辟线程调用 //final关键字可以将paramStr设为方法内共有参数 public void CopyToSystemClipboard(final String paramStr){ Log.d("Unity", "=======CopyToSystemClipboard " + paramStr); //runOnUiThread方法调用一个UI线程 runOnUiThread( new Runnable() { @Override public void run() { // 向剪贴板中添加文本 clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData textCd = ClipData.newPlainText("data", paramStr); clipboard.setPrimaryClip(textCd); mUnityPlayer.UnitySendMessage("GameManagerPrefeb", "OnShowCopySucessMsg", paramStr); } } ); }