This is a security breach. To do this, you must have a root device.
You can use this code with your own application: (I got this code from this answer to another question: fooobar.com/questions/18116 / ... )
// image naming and path to include sd card appending name you choose for file String mPath = Environment.getExternalStorageDirectory().toString() + "/" + ACCUWX.IMAGE_APPEND; // create bitmap screen capture Bitmap bitmap; View v1 = mCurrentUrlMask.getRootView(); v1.setDrawingCacheEnabled(true); bitmap = Bitmap.createBitmap(v1.getDrawingCache()); v1.setDrawingCacheEnabled(false); OutputStream fout = null; imageFile = new File(mPath); try { fout = new FileOutputStream(imageFile); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout); fout.flush(); fout.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
Try finding this code for more reference:
PS You can take a screenshot from Android using DDMS, but this is another story.
PPS If you want to transparently draw your launcher over the reality below it, you need to set the image format to RGBA (only with OpenGL) and process it accordingly. To do this, you do not need to take a screenshot.
Rooted device: use this code on the root device:
process = Runtime.getRuntime().exec("su -c cat /dev/graphics/fb0"); InputStream is = process.getInputStream();
source share