Android 截取设备当前屏幕截图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3318757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:41:48  来源:igfitidea点击:

Taking screenshot of device's current screen

androidscreenshotdevice

提问by Pascal Klein

When one wants to publish his app on the Play Store (previously known as Android Market), he can upload screenshots of his app. I would like to take these screenshots with my current device (Motorola Droid) that I'm using to test the application.

当一个人想在 Play 商店(以前称为 Android Market)上发布他的应用程序时,他可以上传他的应用程序的屏幕截图。我想用我当前用于测试应用程序的设备(摩托罗拉 Droid)截取这些屏幕截图。

There are some apps on the Play Store that allow you to take screenshots, but you have to root your phone, which I don't want to. There are related topics within Stack Overflow where people want to take screenshots out of there code (here). However I just want to take screenshots of my running app with the current device, which is connected via USB to my computer; I'm developing via Eclipse, so there should be a way to tell your running device that it should take a screenshot via the SDK, right?

Play Store 上有一些应用程序可以让您截屏,但您必须将手机设为 root,我不想这样做。Stack Overflow 中有相关主题,人们希望从代码中截取屏幕截图(此处)。但是,我只想使用当前设备截取我正在运行的应用程序的屏幕截图,该设备通过 USB 连接到我的计算机;我正在通过 Eclipse 进行开发,所以应该有一种方法可以告诉您正在运行的设备它应该通过 SDK 截取屏幕截图,对吗?

Some website (e.g. LifeHacker) mention a way to do this,

一些网站(例如LifeHacker)提到了一种方法,

To take a screenshot, you'll be required to enable USB Debugging under the settings, install the Android software development kit, and then connect to the phone with a debug tool

截屏需要在设置下开启USB调试,安装Android软件开发包,然后用调试工具连接手机

but they don't explain what I actually need to do step-by-step.

但他们没有解释我实际需要一步一步做的事情。

I would really appreciate if someone can help me out.

如果有人可以帮助我,我将不胜感激。

回答by Pentium10

Since you probably are a developer, you have SDK and working Eclipse for running Android applications. Just plug in the phone, and make sure you enabled on the Phone the USB Debugging, the device needs to show up in the DDMSperspective of Eclipse.

由于您可能是一名开发人员,因此您拥有用于运行 Android 应用程序的 SDK 和可运行的 Eclipse。只需插入手机,并确保在手机上启用了 USB 调试,设备需要显示在DDMSEclipse的角度。

Once your device shows up in the DDMSperspective there is in icon there to capture the screen.

一旦您的设备出现在DDMS透视图中,就会有一个图标来捕捉屏幕。

回答by Cristian

If you are already using Eclipse to develop your app, then you already have the Android software development kit installed. So, just open the ddmsutility that is on the sdk-android/toolsdirectory. There, you can take screenshots by selecting your device and pressing: Ctrl+S(Device -> Screen capture…).

如果您已经在使用 Eclipse 来开发您的应用程序,那么您已经安装了 Android 软件开发工具包。因此,只需打开目录中的ddms实用程序即可sdk-android/tools。在那里,您可以通过选择您的设备并按:Ctrl+ S设备 -> 屏幕截图...)来截取屏幕截图

ddmslooks like:

ddms好像:

alt text

替代文字

回答by Dan Lew

There's a tool that the Android SDK comes with to help you take screenshots if your device is connected to the computer. I'll explain both. First, for both you need to plug your device into the computer and have it be recognized by adb (aka, when you run "adb devices" it shows your phone).

如果您的设备连接到计算机,Android SDK 附带了一个工具来帮助您截取屏幕截图。我会解释两者。首先,对于两者,您都需要将您的设备插入计算机并让 adb 识别它(也就是,当您运行“adb devices”时,它会显示您的手机)。

Then you can either use Eclipse or DDMS:

然后您可以使用 Eclipse 或 DDMS:

DDMS

数据管理系统

  1. Open ddms.

  2. Click on your device in the list on the left.

  3. Go to the menu Device --> Screen Capture.

  1. 打开ddms

  2. 在左侧列表中单击您的设备。

  3. 转到菜单设备 --> 屏幕捕获。

Eclipse

  1. Open Eclipse.

  2. Open the "devices" view. You can get to it via Window --> Show View --> Other... --> Android --> Devices.

  3. Click on your device.

  4. In the Devices view, there's a little picture in the upper right corner. If you hover your mouse over it it says "Screen Capture." Click that.

  1. 打开日食。

  2. 打开“设备”视图。您可以通过 Window --> Show View --> Other... --> Android --> Devices 访问它。

  3. 单击您的设备。

  4. 在设备视图中,右上角有一张小图片。如果您将鼠标悬停在它上面,它会显示“屏幕截图”。单击那个。

Both methods lead you to the same tool which captures screenshots. Sometimes it can be a little buggy - occasionally I need to close/reopen the window in order to get it to take a screenshot.

这两种方法都会引导您使用相同的工具来捕获屏幕截图。有时它可能有点问题 - 有时我需要关闭/重新打开窗口才能截取屏幕截图。

回答by Tom Chavez

Just noting that ddms is deprecated and this function is now available in the monitor tool (tools/monitor) instead.

请注意,ddms 已被弃用,此功能现在可在监视器工具(工具/监视器)中使用。

Open monitor from a console window and select the device in the left panel. Click the camera (Screen Capture) icon above and you'll see the current screen. Then you can rotate if needed and copy or save the image. Refresh will grab a free screen grab in case you are saving multiple shots or didn't get what you wanted the first time.

从控制台窗口打开监视器并在左侧面板中选择设备。单击上方的相机(屏幕捕获)图标,您将看到当前屏幕。然后您可以根据需要旋转并复制或保存图像。刷新将抓取免费屏幕抓取,以防您保存多张照片或第一次没有得到您想要的东西。