android glsurfaceview空指针异常

前端之家收集整理的这篇文章主要介绍了android glsurfaceview空指针异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我收到这个错误.任何想法 ?
12-29 22:24:46.087: WARN/dalvikvm(2307): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): FATAL EXCEPTION: main
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): java.lang.NullPointerException
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.opengl.GLSurfaceView.surfaceCreated(GLSurfaceView.java:471)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.SurfaceView.updateWindow(SurfaceView.java:532)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.View.draw(View.java:6743)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.View.draw(View.java:6743)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewRoot.draw(ViewRoot.java:1407)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.os.Looper.loop(Looper.java:123)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at android.app.ActivityThread.main(ActivityThread.java:4627)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at java.lang.reflect.Method.invokeNative(Native Method)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at java.lang.reflect.Method.invoke(Method.java:521)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307):     at dalvik.system.NativeStart.main(Native Method)
12-29 22:24:46.167: WARN/ActivityManager(57):   Force finishing activity com.kamil.cakir/.ResimEgici
12-29 22:24:46.667: WARN/ActivityManager(57): Activity pause timeout for HistoryRecord{43fc5250 com.kamil.cakir/.ResimEgici}

解决方法

好的,我找到了解决方案.我有一个实现Renderer接口的GlSurfaceView类.我已经忘记了将渲染器设置成我的视野.
class CustomGl extends GLSurfaceView implements Renderer{

 SquareImage image;
 Context context;
 float rquad = 0.0f;
 public CustomGl(Context context) {
  // TODO Auto-generated constructor stub
  super(context,null);


  //Set this as Renderer
  this.setRenderer(this);    //**I ADDED THIS THE PROBLEM SOLVED!**


  this.context = context;
  this.image = new SquareImage();
  Log.d(VIEW_LOG_TAG,"gl const");
 }

为您的兴趣腾出

原文链接:https://www.f2er.com/android/311485.html

猜你在找的Android相关文章