Using DDMS via Eclipse or through Monitor, it will take the screenshot, but when you copy to clipboard. You can't do anything with it. Gimp, Inkscape, LibreOffice don't recognise what is in the clipboard.
The save option is not that good because the quality it uses to save the png is awful. This makes it difficult to create good quality screenshots for your app. Because of the high resolution of devices the window of the captured screen goes outside the bounds of the desktop/workspace so you can't use a take a screenshot of that window.
Is there another trick to getting around this, like being able to change quality setting ddms saves images? or using adb shell to take screenshots. Is there a screen capture tool in Linux that can take screenshots across workspaces.
ATM I am taking two screenshot one for each workscape the window is on and then using GIMP to line up the images, this takes time, and it is frustrating.
Yes you can take screen shot using adb shell as
adb shell /system/bin/screencap -p /sdcard/img.png
It will be in your sdcard of emulator you can push it out to system ...
I think the above code works from ICS .
Related
I'm trying to generate bitmap image from /dev/graphics/fb0 on Android emulator and it succeeded.
But when I add "-gpu on" option when launch it, it always generate black image.
My code is from here
http://www.pocketmagic.net/android-native-screen-capture-application-using-the-framebuffer/
Without the option, the emulator is too slow for my purpose.
Is there any way to get a screen capture from /dev/graphics/fb0 with -gpu on option?
To avoid unnecessary IO, I don't want to use /syste/bin/screencap.
Thanks for all helps!
I am running calabash-android test for an android application. I need to attach images and videos to a particular section. I can reach the gallery section and after that, I could not select an item from the device library. Is there any way to keep a copy of video and image in my test directory and access the whenever needed? Or is there any solution to access the gallery. And one more thing is that I am integrating the test on Circle-ci later. And I don't know how can I manage it when it is on Circle-ci. All kind of help is appreciated.
Calabash only has access to your app, not anything outside of it.
You will be able to put together a solution using adb to interact with the screen, using touch or keyboard events. However, this will be tied to one specific screen size, as it's done by pixels.
adb shell input tap x y
You could put the images/videos in the directory so they are the most recent, then use adb touch events to select them? It's a bit hacky but it should work.
If I've understood your question correctly, the circle ci part should probably be split out into another question, as it isn't really tied to the previous bit.
EDIT: We ended up getting it to work by running
`adb shell input tap 200 200`
I'd like to know how I can simulate a device taking a screenshot in an android emulator. I know how to take a screenshot of a device but I want to simulate someone taking a screenshot with their actual device.
Any assistance would be appreciated.
You can do it in two ways -
From Eclipse: Windows --> Show view --> other --> Devices.
Once the Devices window is open, you will see a camera icon on the top right side. Click it...
From command line -
Type adb shell and once you're "inside" type screencap name.png (you'll have to do it in a folder with write permission).
After that you can exit the shell and type - adb pull /picture_path/name.png
From Android 4.0, it supports volumn down+power key to take screenshot and saved in gallery. But how to do this in android emulator.
I know in eclipse, there is a 'take screenshot' button, but this is not what I want. I need it in the emulator and saved in emulator.
As seen in this post: Screenshot of the Nexus One from adb?, you can also take a screenshot using adb:
adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png screenshot.png
just click in photo icon for take screenshot in android emulator
In new emulator you can do it by pushing camera icon. By default it saved in desktop.
Window > Show View > Other. In the newly opened dialog box, under Android category, select Devices.
Now on the Devices panel, Click the button as shown in the Image and your screenshot is ready.
You can use ddms which has option to take screen shot.
On DDMS -> Select Device -> Select Screen Capture
Edit
AFIK its not possible but this scenario will solely depend emulator image. Device hotkey might work on some OS images. Try same key combination from emulator link.
If your emulator uses factory or same images then it should be possible. You can download factory images for your emulator. see available nexus images from this link also it is possible to download images from manufacturer site.
Alternatively you can take screen shot following way,
View content = findViewById(R.id.myView);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
And later save this anywhere you like. This is not optimal solution and it will only print what you have inside your view.
Long Press on Power button from the left side menu. then you will have the option for the screenshot.
You can take a screenshot if you open the Android view "devices" (under Window --> Show View --> Other... --> Android --> Devices). Click on the device or emulator you want to take a screen shot of, then click the "Screen Capture" button (it looks like a little picture, and it should be next to a stop sign button). Occasionally the device won't immediately load the picture; sometimes you have to close/reopen the screen capture window.
This is equivalent to taking a picture via DDMS, but you can do it in Eclipse instead of opening another application.
#!/bin/bash -f
while : ; do
echo "press the number of the screenshot to capture";
read i
adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png "${i}.png"
done
ctrl-c
You can simply press the shortcut key i.e. ctlr + S to take screenshot in the emulator.
Also there is a button given on the emulator to take the screenshot.
Simply press
this button button and you'll have a screenshot of the emulator.
Hope that it helped you.
Go to your emulator then press:
ctrl + s
to save your screenshot.
hope its work.
I would need to be able to take screen dumps for testing, and with ICS there is now a screen shot function, that can be invoked by pressing (and holding) volume down and power button.
Is there any way to script this function through adb? (As I understand it there's no public java API for it). I have tried to use KeyEvent from java to emulate power and volume button, and I have tried to use adb keyevent and adb sendevent without success. I suspect that the power button also generate some low level calls that are not generated with the above methods.
So do anyone know if it is possible to call the function from adb?
If this is not possible, do someone know where in the source code this screen shot function exist? Maybe I can figure something out by reading it.
update
source code for capture the screen is in "frameworks/base/services/surfaceflinger/services/surfaceflinger/SurfaceFlinger.cpp" in a function called screenCapture. I do not know if it is possible to call it from jni, but I will try, because it would be great if I could take a screen shot through java.
Otherwise, #edthethird had a solution through android.amberfog.com/?p=168 that will make it possible to take a screenshot with the commandline.
Thank you for the help everyone!
In the form of adb commands, the following works on ICS devices:
adb shell /system/bin/screencap -p /sdcard/img.png
adb pull /sdcard/img.png img.png
See: http://a-more-common-hades.blogspot.com/2012/01/screenshot-command.html
Well this has nothing to do with ICS, but in eclipse, look at a Devices tab. There is a tiny little camera icon on the far right. (From right to left, it is "box", "line", "upside down triangle", and "camera". Click on this camera to take a screen shot of the currently selected device.
This works on any version of Android, not only ICS.
See this question:
Screenshot of the Nexus One from adb?
Basically you can pull the framebuffer using adb and convert it into a usable image yourself, or you can just use the command line utility provided by Google. Looking round I think you may need to tweak that utility a little to get it to work on newer versions of Android.
As the other answer points out though, its probably less hassle to just do this from Eclipse, unless you're trying to automate testing.
After looking into the source code, there is a library that does exactly what I want.
frameworks\base\cmds\screencap\screencap.cpp
The program can be executed on android by /system/bin/screencap .
So it is possible to execute in Java on android by Runtime.getRuntime().exec();
A drawback is that you need a special certificate for taking screenshots.