UnityPlayerActivity:java.lang.RuntimeException:无法在未调用 Looper.prepare() 的线程内创建处理程序
Posted
技术标签:
【中文标题】UnityPlayerActivity:java.lang.RuntimeException:无法在未调用 Looper.prepare() 的线程内创建处理程序【英文标题】:UnityPlayerActivity:java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 【发布时间】:2015-11-12 04:39:41 【问题描述】:当我从 Unity 调用 UnityPlayerActivity 时出现错误。 请帮忙。
androidJavaException: java.lang.RuntimeException: Can not create handler inside the thread that has not called Looper.prepare()
java代码
public class sampleActivity extends UnityPlayerActivity
private mActivity;
private mAppId;
private mLicenseKey;
private mService;
public sampleActivity (Activity activity, String appId, String licenseKey, String service)
mActivity = activity;
mAppId = appId;
mLicenseKey = licenseKey;
mService = service;
cs 代码
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
Plugin = new AndroidJavaObject("com.sample.sampleActivity ",new object[]activity,appId,licenceKey,sku);
【问题讨论】:
该错误通常意味着您正在从工作线程修改或访问 UI 线程。 【参考方案1】:已经解决了
[Closed] JNI Exception using Android Plugin
【讨论】:
以上是关于UnityPlayerActivity:java.lang.RuntimeException:无法在未调用 Looper.prepare() 的线程内创建处理程序的主要内容,如果未能解决你的问题,请参考以下文章
修改UnityPlayerActivity.java并编译为class文件
为 UnityPlayerActivity 设置 android:launchmode
Unity接入北斗探针(基于UnityPlayerActivity)丨五编写Unity代码,完成整个项目