之前网上有很多关于获取GPU信息的帖子,大部分手机都可以获取到,但部分奇葩就不行了。
贴代码:
package com.example.gpuinfo;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
public class OpenGlMainActivity extends Activity {
private GLSurfaceView mGLSurfaceView;
private class Renderer implements GLSurfaceView.Renderer {
public void onDrawFrame(GL10 gl) {
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// 渲染器
Log.e( "GPUINFO", "GL_RENDERER:::::" + gl.glGetString( GL10.GL_RENDERER));
// 供应商
Log.e( "GPUINFO", "GL_VENDOR::::: " + gl.glGetString( GL10.GL_VENDOR));
// 版本
Log.e( "GPUINFO", "GL_VERSION::::: " + gl.glGetString( GL10.GL_VERSION));
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState);
// Create our surface view and set it as the content of our
// Activity
mGLSurfaceView = new GLSurfaceView( this);
mGLSurfaceView.setRenderer( new Renderer());
setContentView( mGLSurfaceView);
}
@Override
protected void onResume() {
// Ideally a game should implement onResume() and onPause()
// to take appropriate action when the activity looses focus
super.onResume();
mGLSurfaceView.onResume();
}
@Override
protected void onPause() {
// Ideally a game should implement onResume() and onPause()
// to take appropriate action when the activity looses focus
super.onPause();
mGLSurfaceView.onPause();
}
}
经测试,三星一个2.2的pad(奇葩)可以获取,coolpad的一个奇葩也能获取,可能还有不能获取的机型,若有提出来大家一起解决。