Вопрос

I am using Genymotion for running android application. Could any one tell me how to capture screen shot in Genymotion ?

Это было полезно?

Решение 3

Disclaimer : I'm part of the same company as the Genymotion team.

This feature is included in the product. It is one of the paid feature of the screencast widget. Look at the pricing page here.

Two ways to access it:

  • pay for the pro or indie licence
  • use the trial version, it offers you the indie features. Be careful, there is only one trial day left :-/

Once your VM is started, open the screencast widget

enter image description here

Then take a picture with the dedicated button

enter image description here

UPDATE: You have bellow another ways to take a screenshot using Android Device Monitor or the command line

Другие советы

If you are using Android Studio or Eclipse, you can just click the button "Screen Capture" in the Android DDMS:

enter image description here

You can use adb to get the screenshot from command line:

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png

This article has the details: http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html

To make my life easier, I made an alias in .bash_profile:

alias screenshot="adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Downloads/android_screenshot.png"

Now I can type screenshot in Terminal and get a screenshot of currently running emulator in my Downloads directory.

Use this commands:

  • Windows:

    C:\"Program Files"\Genymobile\Genymotion\tools\adb shell screencap -p "/mnt/sdcard/output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb pull "/mnt/sdcard/output.png" "C:\output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb shell rm "/mnt/sdcard/output.png"
    
    • Note: Make sure you have permission to write to C:\output.png; otherwise, change it to whatever path you like.
  • OS X:

    /Applications/Genymotion.app/Contents/MacOS/tools/adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/Android_Screenshot_$(date +%Y-%m-%d-%H-%M-%S).png
    
  1. Select genymotion simulator
  2. Hit shortcut key describe below

    • Windows : Ctrl+Shift+S

    • Mac : Cmd+Shift+S

  3. You can find your screenshots at desktop

I think you can also take videos for free. Genymotion uses VirtualBox to do almost all the heavy lifting, so you should open VirtualBox and look at what you can do in it.

You will find options in Virtualbox to capture video! enter image description here

adb shell screencap -p /sdcard/screen.png

If your Mac is slow and you hate running Eclipse and the emulator together here is a quicker way.

  1. Export your apk.
  2. Start Genymotion.
  3. Drag the apk to the emulator, in order to install it.
  4. Go to 'android-sdk-macosx>tools>ddms'.
  5. Run that file.
  6. A new instance of ddms will be started. Unlike Eclipse, it doesn't slow down your system.
  7. Use the 'Menu>Device>Screenshot' option to take screenshot.

This is a good option for those using slow computers.

If you are using Eclipse, then follow the steps for any type of emulator: 1. Select DDMS 2. In Devices window of DDMS select Genymotion device 3. Click on Camera icon then save it to specific location. In Devices window just click on Camera icon. I already mark it by circle here

For Linux and Windows (I used gitbash on windows) adb shell screencap -p | sed 's/\r$//' > screen.png For Mac adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png

@Reck says there's a bug in the Genymotion implementation so we can't take screenshots on 2.3.7. This means that Android Studio / DDMS can't get the proper pixels. adb shell screencap says there's no screencap command.

Assuming you have access to the code you can simply call this method:

public static void screenshot(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    view.draw(new Canvas(bitmap));
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    try {
        File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        storageDir.mkdirs();
        File file = File.createTempFile(timeStamp, ".png", storageDir);
        bitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(file));
        Log.i("SCREENSHOT", "adb pull " + file);
    } catch (IOException e) {
        Log.e("SCREENSHOT", "Cannot save screenshot of " + view, e);
    }
}

In Activity:

screenshot(getWindow().getDecorView());

In Fragment:

screenshot(getActivity().getWindow().getDecorView());

The only limitation I know is that it won't include the status bar.

if you use Mac, sometimes CMD + Shift + 4 (screenshot of a selected portion in OSX ) and then selecting the simulator region is enough :)

Take a screenshot

On many Android devices, you can capture a screenshot with a key-combination: Simultaneously press-and-hold Power and Volume-down. You can also capture a screenshot with Android Studio as follows:

Run your app on a connected device or emulator. If using a connected device, be sure you have enabled USB debugging. In Android Studio, select View > Tool Windows > Logcat to open Logcat. Select the device and a process from the drop-down at the top of the window. Click Screen Capture on the left side of the window. The screenshot appears in a Screenshot Editor window

It Works for even Genymotion Emulator

Check here for further information

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top