Get screenshots of other running apps on android

On Android I can get list of running applications by executing getRunningAppProcesses on activity manager:

        ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();

But I want something more, when I open system task manager, there are screenshots of running applications, like on Screenshot Can I get those screenshots in my own application? How to get image representing contents of given window?



take screenshot without needs root access:

    public void takeScreenshot(Context context, String fileFullPath)
        if(fileFullPath == ""){
            format = new SimpleDateFormat("yyyyMMddHHmmss");
            String fileName = format.format(new Date(System.currentTimeMillis())) + ".png";
            fileFullPath = "/data/local/tmp/" + fileName;

            if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
                ShellUtils.execCommand("/system/bin/screencap -p "+ fileFullPath,true);
        else {
            if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2 && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
                wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
                mDisplay = wm.getDefaultDisplay();
                mDisplayMatrix = new Matrix();
                mDisplayMetrics = new DisplayMetrics();
                // We need to orient the screenshot correctly (and the Surface api seems to take screenshots
                // only in the natural orientation of the device :!)
                float[] dims =
                        mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels
                float degrees = getDegreesForRotation(mDisplay.getRotation());
                boolean requiresRotation = (degrees > 0);
                if (requiresRotation){
                    // Get the dimensions of the device in its native orientation
                    dims[0] = Math.abs(dims[0]);
                    dims[1] = Math.abs(dims[1]);

                Bitmap mScreenBitmap = screenShot((int) dims[0], (int) dims[1]);
                if (requiresRotation)   {
                    // Rotate the screenshot to the current orientation
                    Bitmap ss = Bitmap.createBitmap(mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels,
                    Canvas c = new Canvas(ss);
                    c.translate(ss.getWidth() / 2, ss.getHeight() / 2);
                    c.translate(-dims[0] / 2, -dims[1] / 2);
                    c.drawBitmap(mScreenBitmap, 0, 0, null);
                    mScreenBitmap = ss;
                    if (ss != null && !ss.isRecycled()) {

                // If we couldn't take the screenshot, notify the user
                if (mScreenBitmap == null){
                    Toast.makeText(context, "screen shot fail", Toast.LENGTH_SHORT).show();

                // Optimizations

                saveBitmap2file(context, mScreenBitmap, fileFullPath);  // save image file



Need Your Help

Image cannot been displayed with strange name

php html image file-upload

I have a code that let my users to upload images and it works fine till I discoverd when the image file name is something like this "Suzuki_Swift_1.2_Comfort_(FZ_NZ)_–_Frontansicht,_26._März_20...

SubSonic 3.0 , I'm missing SubSonic.Query

c# subsonic subsonic3

I probably missed something in the .tt configuration for some reason my intellisense when I type SubSonic.Query or Query = new Query(DB.Table) is not highlighting and giving me an error. Anybody ha...