简体   繁体   English

我可以以编程方式截取主屏幕,而无需root我的Android设备吗?

[英]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.

相关问题 用于生根设备的Android屏幕截图捕获 - Android screenshot capture for rooting device 如何在没有root设备的情况下捕获其他Android应用程序的屏幕截图? - How to capture a screenshot of other Android application without rooting device? 是否可以在不植根设备的情况下以编程方式触摸屏幕上的事件? - Is it possible to touch event on screen programmatically without rooting the device? Android手机中的屏幕截图没有生根 - Screenshot in Android phone without rooting 如何在没有root设备的情况下隐藏Android设备中的任何应用程序? - How to hide any application in android device without rooting my device? 如何以编程方式截取 Android 中的整个屏幕? - How to take screenshot of entire screen in Android programmatically? 如何在Android中以编程方式截取整个屏幕 - How take screenshot of entire screen programmatically in Android 如何在不生根的情况下从我的android设备监视器访问数据/数据? - how can I accesses to data/data from my android device monitor with out rooting my phone? 以编程方式获取Android屏幕截图-屏幕应用上的所有内容都可能位于后台而非根目录设备中 - Take Android Screenshot programmatically-whatever on screen-app may be in background-not rooted device 如何截取屏幕截图并将其保存在内部存储中? 安卓 - How can I take a screenshot of my screen and save it on Internal Storage? Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM