I am using the HelloAR demo application and I am trying to take a screenshot of the entire screen (menu bar and everything). I am able to take a screenshot, but not everything is captured... GUI elements are visible in the screenshot, but the camera feed is not.
Here is my code:
int counter = 0;
private void takeScreenShot()
{
View view = getWindow().getDecorView().getRootView();
Bitmap bmp = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
PixelCopy.request(getWindow(), bmp, copyResult -> {
if(copyResult == PixelCopy.SUCCESS){
String filename = getExternalFilesDir(null) + File.separator + "SCREENSHOTS" + File.seperator + "SS_" + counter + ".png";
store(bmp, filename);
counter++;
}
}, new Handler());
}
public static void storeit(Bitmap bm, String fileName){
File file = new File(fileName);
try {
FileOutputStream fOut = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
And here is what the screenshot looks like:
How can I capture the entire screen (camera feed, UI elements, menu bar, etc.)?