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
Related
I use command
adb shell screenrecord/sdcard/misscall.mp4
To record my screen. But affter 20-25s, it stop record
I want to record a video has duaration about 3 minute
Anyone can help me
Maybe do "screenrecord -d 180 /sdcard/thenameyouput.mp4
You can try screenrecording directly through Android Studio. When you plug in your device while Android Studio is open, the Android Monitor should appear for your device. On the left hand side of that panel, there is a green play button that you can click to screen record. As far as I know, you can start and stop the video on command as well as choose a place to save the file.
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 .
I'm able to run my Uiautomator test cases on emulator easily, on both API 16 and 17.
If I run same test case on real device it get stuck in the 1st line only.
I'm not sure with the steps to run on the real device
UiScrollable has some issue, I guess. When I write getUiDevice().pressHome(); it works, but after that nothing works. I'm using the same code written in the Android developer site for Uiautomator (http://developer.android.com/tools/testing/testing_ui.html)
Use uiautomatorviewer to dump the UI hierarchy of your device's home screen. As user2575698 says, it is likely that there is no UiObject with description "Apps".
Also you have to keep in mind that the sample from the android developer site requires the device to have the screen on and that no screen lock is present. Making sure that the screen is on can be done in the following way:
UiDevice device = getUiDevice();
if (!device.isScreenOn()) {
device.wakeUp();
}
device.pressHome();
Screen lock can be disabled in Settings.
Maybe it cannot find the object with description "Apps" on your real devices,you need to give logs for detail things
use "adb shell uiautomator dump " command to get window dump. Then to to sd card and look for dump xml. There look for content-desc attribute of node and code according to that value. content-desc can be different on different device as for application in samsung it is "Apps" but in HTC one it is "All apps".
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've started creating a MonkeyRunner script. This is going ok, but whenever I add a MonkeyDevice::touch command, I have to determine the input coordinates by trial-and-error. Basically I guess at the coordinates I want to touch and see if those coordinates result in the button touch I'm trying to test. That works, but it's a slow process. Is there anyway to determine the coordinates of UI controls, perhaps from the layout XML files?
I found how to do it. Use the Pixel Perfect view within Eclipse to determine the x & y coordinates of the UI element. Here's a quick overview:
1) Eclipse must be running
2) Your Android device must be connected (either the real device via ADB, or the emulator)
3) Run the hierarchy viewer (in /tools)
4) Select "Inspect screenshot"
The Pixel Perfect view will launch automatically. Just place the cross-hairs on the UI element. The x and y coordinates, along with the RGB values, are displayed below.
Here's the URL that got me started: http://developer.android.com/guide/developing/debugging/debugging-ui.html#pixelperfect
This post (monkeyrunner: interacting with views), may give you and idea of how to obtain the View's coordinates using AndroidViewClient.
Most of the Android versions you can enable pointer location in Settings->Developer Options. Once you enable it, it is easy to find out the (x,y) coordinates.
you can also use the HierarchyViewer tool in your AndroidSDK>tools folder to take screenshots of the current screen and examine that image pixel by pixel to get exact coordinates.
For devices older than Android 4.0, see the paragraph following this one. Android 4.0 and later include Settings->Developer options->Pointer location toggle which toggles a transparent ribbon across the top of the device screen with coordinates, velocities and touch-pressure readings including swipe tracks and x/y crosshairs for the current touch location. This is a lot easier than using alternatives such as Monkey Recorder and other means. In Android 4.2 and later, Developer options is hidden from the Settings menu and must be enabled by going to Settings->About tablet and tapping on Build number seven times. One can only presume that Android hid Developer options because of the increasingly user-experience-affecting options it contains and the number of consumer calls/complaints to device makers from people who played with it or whose children played with it.
In older versions which may not include a Pointer location toggle, there is an app on the Play Store (aka Android Market), Developers Tools. See link here: https://play.google.com/store/apps/details?id=com.ggb.development
It will show up with a gear icon and the caption Dev Tools on a device and provide similar functionality which Dev Tools in an AVD (Android Virtual Device) has. That includes Dev Tools ->Development settings>No Pointer Location/Pointer Location radio button toggle. Setting that toggle to Pointer Location provides the exact same functionality built-in with Android 4.0 and later. The same application also has a more limited pointer setting at Dev Tools->Pointer Location which limits pointer location to only a blank screen.
Enjoy!
Create a xyz.py file with below code and connect the device and run it in terminal like monkeyrunner xyz.py, then you will get your device in pc, then u click on any button in the recorder it will give you the coordinates, after that explore it to any file and you can use the coordinates.
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
device = mr.waitForConnection()
recorder.start(device)
I found an adb approach. Use adb shell getevent -l to get a list of events, grep for ABS_MT_POSITION (gets the line with touch events in hex) and finally use awk to get the relevant hex values, strip them of zeros and convert hex to decimal that monkey runner uses. This is all done with the following:
adb shell getevent -l | grep ABS_MT_POSITION --line-buffered | awk '{a = substr($0,54,8); sub(/^0+/, "", a); b = sprintf("0x%s",a); printf("%d\n",strtonum(b))}'
This continuously prints the x and y coordinates in the terminal only when you press on the device.