It is possible to partially support screenshots within your own app. This is essentially done by getting the content root view of your Activity and rendering it against a Canvas.
The code below does just that. (Source excerpt from the android-beryl library.)
public class Screenshot { private final View view; /** Create snapshots based on the view and its children. */ public Screenshot(View root) { this.view = root; } /** Create snapshot handler that captures the root of the whole activity. */ public Screenshot(Activity activity) { final View contentView = activity.findViewById(android.R.id.content); this.view = contentView.getRootView(); } /** Take a snapshot of the view. */ public Bitmap snap() { Bitmap bitmap = Bitmap.createBitmap(this.view.getWidth(), this.view.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); return bitmap; } }
Interesting, but shouldn't a file for the screenshot picture be created and saved?
ReplyDeleteYou can save the bitmap to a file by using Bitmap.compress() as described here: http://stackoverflow.com/a/673014/379245
Deletewhat code to share image on social
ReplyDeleteLuckyLand Casino (Washington, D.C) - Mapyro
ReplyDeleteThis site 김포 출장마사지 is no 김해 출장마사지 longer available. See 안동 출장마사지 map. LuckyLand Casino is open. Please contact us for 태백 출장마사지 questions or suggestions. Rating: 5 · 광양 출장샵 1 review