I have a requirement that I have to take a screenshot of the current window in android. This is the code am using,
View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
View screenView = rootView.getRootView();
screenView.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
screenView.setDrawingCacheEnabled(false);
by using this I could get the application screen shot, but the status bar contents are missing (bluetooth icon, battery status etc). How can I take a screenshot of the current Android phone window programmatically (including status bar contents)? Is it possible?
On Android 5.0+, use the media projection APIs to take a screenshot of the device screen. See this sample app, as the process is somewhat involved.
On older Android devices, there is no support for programmatic screenshots of the device screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With