Thank you for your reply! And I had figured out why it didn't work. You are right. My frame buffer was empty. To solve this problem, I just put the getPixels() method in the onDrawFrame like this:
```
public int[] tmpPixels;// Global variance
public void onDrawFrame(GL10 gl) {
tmpPixels = fb.getPixels();
fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();
}
```
Then I convert the int array (tmpPixels) to bitmap and save it in my dispatchKeyEvent like this way:
```
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_DOWN) {
Bitmap lastImage = Bitmap.createBitmap(fb.getWidth(), fb.getHeight(), Bitmap.Config.ARGB_4444);
lastImage.copyPixelsFromBuffer(IntBuffer.wrap(tmpPixels));
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/my_jpg_test");
Log.i("JPCT","My File path" + sdCard.getAbsolutePath() + "/my_jpg_test");
dir.mkdirs();
String fileName = String.format("The.jpg");
File outFile = new File(dir, fileName);
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(outFile);
int quality = 100;
lastImage.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
```
And it works!
By the way, obviously, the program becomes extremely slow by using tmpPixels to record the pixel of image on onDrawFrame in this way. Of course I will use some flags to control this process. Thanks again!