1

我正在尝试将统一播放器设置为壁纸引擎

代码:

private class MyWallpaperEngine extends Engine{
    UnityPlayer mUnityPlayer;
    @Override
    public void onCreate(SurfaceHolder surfaceHolder) {

        mUnityPlayer = new UnityPlayer(MyWallpaperService.this);
        int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
        boolean trueColor8888 = false;
        mUnityPlayer.init(glesMode, trueColor8888); //line 33
        super.onCreate(surfaceHolder);
    }.....

我遇到的错误:

05-22 15:57:37.809  23088-23088/?                              E/AndroidRuntime: FATAL EXCEPTION: main
        java.lang.Error: FATAL EXCEPTION [main]
        Unity version     : 4.1.2f1
        Device model      : LGE Nexus 4
        Device fingerprint: google/occam/mako:4.2.2/JDQ39/573038:user/release-keys
        Caused by: java.lang.NullPointerException
        at com.unity3d.player.g.a(Unknown Source)
        at com.unity3d.player.g.b(Unknown Source)
        at com.unity3d.player.UnityPlayer.resume(Unknown Source)
        at com.unity3d.player.UnityPlayer.a(Unknown Source)
        at com.unity3d.player.UnityPlayer.init(Unknown Source)
        at com.Company.ProductName.MyWallpaperService$MyWallpaperEngine.onCreate(MyWallpaperService.java:33)
        at android.service.wallpaper.WallpaperService$Engine.attach(WallpaperService.java:777)
        at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:1037)
        at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:40)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5041)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
        at dalvik.system.NativeStart.main(Native Method)

有什么想法有什么问题吗?我应该使用另一个上下文(如何)?提前致谢

4

0 回答 0