problem Initializing the GLview in android
<p>I have written the following code to initialize the GLview in android. I am relatively new to android application development. I want to use the code for getting the screen capture.</p>

<p>Here is the piece of code I have written:</p>

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

    /** Called when the activity is first created. */

    private EGL10 egl;
    private EGLDisplay display;
    private EGLConfig config;
    Display disp ;
    private EGLContext eglContext;
    private GL10 gl ;
    private EGLSurface surface;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        // ToDo add your GUI initialization code here        
    setContentView(R.layout.main);

    disp = getWindowManager().getDefaultDisplay();

    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);

    SurfaceView view = new SurfaceView(this);
    setContentView(view); 

      SurfaceHolder holder = view.getHolder();
      holder.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
      try{
            surface = egl.eglCreateWindowSurface(display,config, holder , null);
      }catch(Exception e)
      {
          e.printStackTrace();
      }
    egl.eglMakeCurrent(display, surface, surface, eglContext);
    gl = (GL10) eglContext.getGL();




    savePNG(0,0,disp.getWidth(), disp.getHeight(),"testpicture.png",gl);


    }
</code></pre>

<p>But the application is terminating at</p>

<pre><code>      try{
            surface = egl.eglCreateWindowSurface(display,config, holder , null);
      }catch(Exception e)
      {
          e.printStackTrace();
      }
</code></pre>

<p>It is giving the exception</p>

<pre><code> IlligalArgument exception: Must use SurfaceHolder or SurfaceView  with proper format. not a valid surface.
</code></pre>

<p>please rectify this problem.</p>

<p>Thank you.</p>
