I already have a method that takes a screenshot of my application's window but naturally this doesn't really give me what is drawn on my SurfaceViews. Taken from elsewhere on SO:
File directory = new File(Environment.getExternalStorageDirectory()+File.separator+"myFolder");
directory.mkdirs();
String path = directory.getAbsolutePath().toString()+"/"+ "something"+".jpeg";
// create bitmap screen capture
View v1 = getActivity().getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(path);
//displays my newly created file in file explorer when connected to a desktop
MediaScannerConnection.scanFile(context, new String[]{path}, null, null);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
Now, I found Android's way of making a screenshot and it does it beautifully (maybe not too fast) when pressing the power and volume buttons here and here.
Can I use this service from my app, and if I can how could I do it? Looking at the source I tried maybe taking only the bits of code that saves the whole of the screen without the notifications and animations(and with the added bonus of my determining the destination folder) but I'm a bit lost to what precisely I'd need. Thank you.