Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to access emulator screenshot via emulator?

My app allows the user to take a screenshot which it then sends to the server.

On a real device, the screenshots are saved at /storage/emulated/0/Pictures/Screenshots/ so that is fine.

But on the emulator, when I click the Take screenshot button (which is located in the panel beside the emulator), the screenshot is saved to my computer, but I can't find it anywhere in the emulator's file system - the /storage/emulated/0/Pictures/ directory exists, but the /storage/emulated/0/Pictures/Screenshots/ sub-directory does not.

Is there any way I can access the screenshot image on the emulator, or is there another way of taking the screenshot?

like image 381
ban-geoengineering Avatar asked Jun 12 '17 09:06

ban-geoengineering


People also ask

Where are Android Emulator screenshots saved?

Press for 3 dots. Then Press the Settings and in top right corner you will see the screenshot folder location.

How do you screenshot on Andy emulator PC?

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.


2 Answers

Emulate Volume Down + Power event to trigger Android's screenshot, then screenshot pictures will be stored at emulator's /storage/emulated/0/Pictures/Screenshots.

Here is the script. Run adb shell, then copy the code below and run, you should see the emulator start taking a screenshot.

cat > /data/local/tmp/screenshot.sh <<EOF
#!/bin/sh
echo 'volume key: down'
sendevent /dev/input/event1 1 114 1
echo 'power key: down'
sendevent /dev/input/event1 1 116 1
sendevent /dev/input/event1 0 0 0
sleep 1
echo 'volume key: up'
sendevent /dev/input/event1 1 114 0
echo 'power key: up'
sendevent /dev/input/event1 1 116 0
sendevent /dev/input/event1 0 0 0
EOF
sh /data/local/tmp/screenshot.sh

NOTE: My emulator's input device is "/dev/input/event1", this may be different for other devices. You can get the device info by running adb shell getevent command, then press the emulator's key, the output will be something like this(My Volume Down key, these are hex numbers, so 0x0072 is 114d):

/dev/input/event1: 0001 0072 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0001 0072 00000000
/dev/input/event1: 0000 0000 00000000
like image 60
wrkwrk Avatar answered Oct 19 '22 23:10

wrkwrk


It will save in your PC . You can also specify the location of screenshots from the emulator settings.

Please see the following image for reference.

enter image description here

like image 20
Don Chakkappan Avatar answered Oct 20 '22 00:10

Don Chakkappan