If you just want to take a screenshot very directly:
public Bitmap screenShot(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); return bitmap; }
just call this method with the view in which you want to take a picture .. so if you want the whole screen to simply go to the top of the ViewGroup . if you want the system controls to also call:
screenShot((ViewGroup) view.getParent());
Now, if you are interested in how the volume + power keys work, deeper in the OS than you will have access too. Unable to intercept the power button from APK AFAIK.
Justin morris
source share