[英]Can I take screenshot of home screen programmatically ,without rooting my android device?
I want to take screenshot of my home screen .How can I achieve this ? 我想截取我的主屏幕截图。我怎么能实现这个目标? I am able to take screenshots of current activity but not the home screen .
我可以截取当前活动的屏幕截图,但不能截取主屏幕。
My codes for taking screenshot of current activity is 截取当前活动截图的代码是
View v1 = linearlayout_var.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
imageview.setBackgroundDrawable(bitmapDrawable);
If i want to take the screenshot of Home screen ,what I should use instead of linearlayout_var so that I can reach the root view of home screen . 如果我想拍摄主屏幕的屏幕截图,我应该使用而不是linearlayout_var,以便我可以到达主屏幕的根视图。
In single line my question is how to get the root view of Homescreen ?? 单行我的问题是如何获得Homescreen的根视图?
Try this one 试试这个吧
getWindow().getDecorView().findViewById(android.R.id.content);
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.