Trying to get screenshot
<p>I'd like to get screenshot through OpenGL on Android. Although, I've found some code which do it, but it doesn't work!
Code snippet:</p>

<pre><code>public class RemoteManager extends Activity {

Bitmap mSavedBM;
private EGL10 egl;
private EGLDisplay display;
private EGLConfig config;
private EGLSurface surface;
private EGLContext eglContext;
private GL11 gl;

protected int width, height;    

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);      

 // get the screen width and height
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);        
    int screenWidth = dm.widthPixels;
    int screenHeight = dm.heightPixels;

    String SCREENSHOT_DIR = "/screenshots";        
    initGLFr(); //GlView initialized.
    savePixels( 0, 10, screenWidth, screenHeight, gl); //this gets the screen to the mSavedBM.
    saveBitmap(mSavedBM, SCREENSHOT_DIR, "capturedImage");*/
    //Now we need to save the bitmap (the screen capture) to some location.
    setContentView(R.layout.main);
}    

private void initGLFr()
{
egl = (EGL10) EGLContext.getEGL();
display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
int[] ver = new int[2];
egl.eglInitialize(display, ver);

int[] configSpec = {EGL10.EGL_NONE};
EGLConfig[] configOut = new EGLConfig[1];
int[] nConfig = new int[1];
egl.eglChooseConfig(display, configSpec, configOut, 1, nConfig);
config = configOut[0]; 
eglContext = egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, null);
GLSurfaceView surfaceView = new GLSurfaceView(this); 
SurfaceHolder holder = surfaceView.getHolder(); 
   //GETTING ERROR!!!
surface = egl.eglCreateWindowSurface(display, config, holder, null);
egl.eglMakeCurrent(display, surface, surface, eglContext);
gl = (GL11) eglContext.getGL();

}
..........
..........
}
</code></pre>

<p><strong>Error:</strong></p>

<blockquote>
  <p>09-26 05:05:32.256: ERROR/AndroidRuntime(946): Caused by:
  java.lang.IllegalArgumentException: Make sure the SurfaceView or
  associated SurfaceHolder has a valid Surface</p>
  
  <p>09-26 05:05:32.256: ERROR/AndroidRuntime(946):     at 
  com.google.android.gles_jni.EGLImpl._eglCreateWindowSurface(Native
  Method)</p>
  
  <p>09-26 05:05:32.256: ERROR/AndroidRuntime(946):     at
  com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:87)</p>
  
  <p>09-26 05:05:32.256: ERROR/AndroidRuntime(946):     at
  com.ares.RemoteManager.initGLFr(RemoteManager.java:95)</p>
</blockquote>

<p>What do I wrong? 
If anybody knows how to get screenshot other way, I'll appreciate it. Help me please!</p>
