简体   繁体   中英

Take Screenshot of the current view in Android

I'm very new to Android. And I have created a system overlay (similar to Facebook chat heads). Now I want to take the screen shot of the current view (where the system overlay is present) progrmatically. System overlay can be in top of any activity, my goal is get the screenshot of any activity.

Is it possible to do so?

Thanks in advance.

Is it possible to do so?

No. You can't get a screenshot of any other app's Activity programmatically.

The only thing you can get from this is the overlay itself.
You can easily try it with this method, save the bitmap to storage, and then display it with your gallery app.
You will only see the overlay content, but nothing below.

    public static Bitmap createBitmapFromView(View v) {
        Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        v.draw(canvas);
        return bitmap;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM