生活随笔
收集整理的這篇文章主要介紹了
Android OpenGL动态壁纸问题总结
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
打開動態壁紙時一直顯示動態壁紙正在加載
報錯信息: 無!(這是最難受的 /(ㄒoㄒ)/~~ )。
問題原因: 粗心導致!把本應返回的MyEngine對象寫成了Engine。
問題代碼塊:
public class MyGLWallpaperService extends WallpaperService {@Overridepublic Engine
onCreateEngine() {return new Engine();}class MyEngine extends Engine{}
}
問題代碼: return new Engine();
解決辦法: 將onCreateEngine()方法中返回的Engine改成MyEngine。
總結:本來百思不得其解,百度亦不得其解,但在不經意間掠過了代碼的某一處就發現問題所在,真是造化弄人啊!所以同志們,在遇到這種bug時先不要worry,可能只是緣分未到,一定要按時睡覺!!!
打開動態壁紙時程序直接崩潰,顯示xxxActivity已停止運行
報錯信息: A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 2128 (GLThread 115)
問題原因: GLThread報錯,具體未知(如果有知道的,歡迎評論指教)。
問題代碼塊:
class MyEngine extends Engine{GLSurfaceView glView
= null
;MyRender render
= null
;private void onCreate(SurfaceHolder holder
){super.onCreate(holder
);glView
= new GLSurfaceView(MyGLWallpaperService
.this);final ActivityManager activityManager
= (ActivityManager
) getSystemService(ACTIVITY_SERVICE
);final ConfigurationInfo configurationInfo
= activityManager
.getDeviceConfigurationInfo();final boolean supportsEs2
= configurationInfo
.reqGlEsVersion
>= 0x20000||(Build
.VERSION
.SDK_INT
>= Build
.VERSION_CODES
.ICE_CREAM_SANDWICH_MR1
)&&(Build
.FINGERPRINT
.startsWith("generic"))|| Build
.FINGERPRINT
.startsWith("unknow")|| Build
.MODEL
.contains("google_sdk")|| Build
.MODEL
.contains("Emulator")|| Build
.MODEL
.contains("Android SDK built for x86");if(supportsEs2
){glView
.setEGLContextClientVersion(2);render
= new MyRender(MyGLWallpaperService
.this);glView
.setRenderer(render
);}else{Toast
.makeText(MyGLWallpaperService
.this ,"This device does not support OpenGL ES 2.0",Toast
.LENGTH_LONG
).show();}}}
問題代碼: glView.setEGLContextClientVersion(2);
解決辦法: 將glView.setEGLContextClientVersion(2);刪掉。
總結:適合別人的代碼不一定適合自己!
總結
以上是生活随笔為你收集整理的Android OpenGL动态壁纸问题总结的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。