how can I screen capture via android.I mean I want to write a program which make a screenshot of the screen.any link appreciated ,thank you all
Asked
Active
Viewed 503 times
-1
-
Of your app or of any app? – FD_ Feb 18 '14 at 10:08
-
what??can u give me details – sakir Feb 18 '14 at 10:09
-
Do you want to take a screenshot of your own app, or of any app? – FD_ Feb 18 '14 at 10:10
-
any app running on the phone – sakir Feb 18 '14 at 10:10
-
thank you parmar,yea it seems dublicated – sakir Feb 18 '14 at 10:12
-
Simply, you can't! You can only shoot your app – Phantômaxx Feb 18 '14 at 10:13
2 Answers
3
This is not possible as easily as you'd like it to. There is no official API for that for security reasons.
Here are your options:
- Using the screencap command line tool: Needs root permission, not installed on all phones
- Getting the frame buffer: Requires root
- Using android-screenshot-library: Requires adb connection for start

FD_
- 12,947
- 4
- 35
- 62
1
I use this code to take a screenshot of MY APP (you can't take a picture of other apps):
@SuppressLint("SimpleDateFormat")
protected final static boolean shoot
(final View v, final String appName)
{
// Get the bitmap from the view
v.setDrawingCacheEnabled(true);
boolean isOK = false;
final Bitmap bmp = v.getDrawingCache();
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd@HHmmss");
final Calendar cal = Calendar.getInstance();
// Set file properties
fileJPG = appName + "_" + sdf.format(cal.getTime());
/*
Create a path where we will place our picture in the user's public
pictures directory. Note that you should be careful about what you
place here, since the user often manages these files.
For pictures and other media owned by the application, consider
Context.getExternalMediaDir().
*/
final File path =
Environment.getExternalStoragePublicDirectory
(
Environment.DIRECTORY_DCIM + "/Your_App_Name/"
);
// Make sure the Pictures directory exists.
if(!path.exists())
{
path.mkdirs();
}
final File file = new File(path, fileJPG + ".jpg");
try
{
final FileOutputStream fos = new FileOutputStream(file);
final BufferedOutputStream bos =
new BufferedOutputStream(fos, 8192);
bmp.compress(CompressFormat.JPEG, 85, bos);
bos.flush();
bos.close();
fileJPG = file.getPath();
isOK = true;
}
catch (final IOException e)
{
e.printStackTrace();
}
return isOK;
}

Phantômaxx
- 37,901
- 21
- 84
- 115
-
I just downloaded a programe whick take a screenshot of any app.how that possiable – sakir Feb 18 '14 at 10:16
-
-
-
-
So, it's very strange, since you normally don't have the permissions to do that. See FD_'s answer for details – Phantômaxx Feb 18 '14 at 10:18
-
I just press power button and voice down buttun at the same time and get the screen shot of any app.I also no rooted ,I am confused – sakir Feb 18 '14 at 10:19
-
1See if [this link](http://stackoverflow.com/a/15186761/2649012) or [this one](http://stackoverflow.com/a/15208592/2649012) will solve your problem. – Phantômaxx Feb 18 '14 at 10:26