I've created a Service which runs on top of other apps. I want the service to take a screenshot of the entire screen as the user sees it regardless of what apps are running. Can I have the service run the screenshot function of the phone and store it in a specific location?
Asked
Active
Viewed 4,594 times
0
-
As far as I know, this can't be done. You can only take a screenshot of what is in YOUR app. – Phantômaxx Feb 13 '14 at 17:06
2 Answers
3
Can I have the service run the screenshot function of the phone and store it in a specific location?
No, except perhaps on rooted devices, for obvious privacy and security reasons.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
0
well, similar questions have been really popular on stackoverflow:
How to programmatically take a screenshot in Android?
How to take screenshot programmatically?
how to take screenshot programmatically and save it on gallery?
Especially, this one is usefull:
// 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) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
by Mualig, from one of the posts above.

Community
- 1
- 1

Niklas Zantner
- 182
- 2
- 16