gpt4 book ai didi

android - 无法恢复 Activity -运行时异常

转载 作者:行者123 更新时间:2023-12-02 17:49:13 27 4
gpt4 key购买 nike

     @Override
public void onResume()
{
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_7, this, mLoaderCallback);
}

public void onDestroy() {
super.onDestroy();

}

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{

Log.i(TAG, "OpenCV loaded successfully...................");
}
}
default:
{
super.onManagerConnected(status);
} break;
}
}
};

这是我的日志

0java.lang.RuntimeException: Unable to resume activity {com.example.lowfreq/com.example.lowfreq.Sample}: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@41b9aca8 is not valid; is your activity running? 1 at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2814) 2 at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2843) 3 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2278) 4 at android.app.ActivityThread.access$800(ActivityThread.java:138) 5 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1236) 6 at android.os.Handler.dispatchMessage(Handler.java:102) 7 at android.os.Looper.loop(Looper.java:149) 8 at android.app.ActivityThread.main(ActivityThread.java:5045) 9 at java.lang.reflect.Method.invokeNative(Native Method) 10 at java.lang.reflect.Method.invoke(Method.java:515) 11 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 12 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 13 at dalvik.system.NativeStart.main(Native Method) 14Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@41b9aca8 is not valid; is your activity running? 15 at android.view.ViewRootImpl.setView(ViewRootImpl.java:561) 16 at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259) 17 at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) 18 at android.app.Dialog.show(Dialog.java:287) 19 at org.opencv.android.BaseLoaderCallback.onPackageInstall(BaseLoaderCallback.java:110) 20 at org.opencv.android.AsyncServiceHelper.InstallService(AsyncServiceHelper.java:116) 21 at org.opencv.android.AsyncServiceHelper.initOpenCV(AsyncServiceHelper.java:32) 22 at org.opencv.android.OpenCVLoader.initAsync(OpenCVLoader.java:60) 23 at com.example.lowfreq.Sample.onResume(Sample.java:189) 24 at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1194) 25 at android.app.Activity.performResume(Activity.java:5315) 26 at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2804)



OPEN CV的初始化方式是否有错误?

最佳答案

尝试使用getApplicationContext()代替this中的OpenCVLoader.initAsync(..)

原因:Should I use getApplicationContext or Activity.this in a long running AsyncTask

关于android - 无法恢复 Activity -运行时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27226513/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com