What brings me here?
When I do Android stuff, my mind switches to survival mode; I try to make the best of what I have. Assuming you do as well, I present to you some of the tricks I use to make my sure demise a bit less terrible.
- Native Screenshots on Android Emulator
- Shaking the Emulator
- Swiping with 2 fingers
Equipped with these tricks, you may now go on hating on Android as you were, with double the fingers and a good shake.
Trigger Native Screenshots on AVD
This will help you trigger a native screen capture event on a device that you don’t have physical access to (Virtual devices/ emulators).
Support: Up to
- Hold down the power button on the emulator’s sidebar
- Click on the Screenshot icon
This way is quite flexible; it simulates a key press on the device’s GPIO buttons (Power, volume…etc).
Support: All API versions
- Configure the adb shell to run with root privileges
- Determine your device id:
adb shell getevent
On the emulator click on any of the volume buttons, and observe the terminal. You should see output similar to this:
/dev/input/event12: 0001 0072 00000001
This makes your device id:
- Start the adb shell
- Copy this script and make sure to substitute the device id with yours.
cat > /data/local/tmp/snap.sh <<EOF #!/bin/sh echo ‘volume key: down’ sendevent /dev/input/event12 1 114 1 echo ‘power key: down’ sendevent /dev/input/event12 1 116 1 sendevent /dev/input/event12 0 0 0 sleep 1 echo ‘volume key: up’ sendevent /dev/input/event12 1 114 0 echo ‘power key: up’ sendevent /dev/input/event12 1 116 0 sendevent /dev/input/event12 0 0 0 EOF
Paste the script in your adb shell (This script holds down the power and volume-down buttons for one second, then releases them.)
- Take Screenshots
Shaking the emulator
This one is simple (android simple that is). All you have to do is:
- Go to emulator settings (the 3 dots thingy)
- Virtual Sensors
- Device Pose
- Select Move
- Have fun with any of the sliders
Swiping with 2 fingers
Often we like to swipe with 2 fingers on an emulator. I was writing a script for it. But I found out it’s natively (and horribly) supported now. I’ve recorded a video showing the required keystrokes (yep they’re quite a few) and I’ll also list them here:
- Hold ⇧ Shift
- Hold ⌘ Command
- Slightly move your mouse cursor so that you have 2 aligned-circles representing 2 fingers
- Now Right-Click with your mouse and swipe into the required direction.
That’s right 4 convoluted steps and they require a mouse (the trackpad won’t work). That’s what you get when working with Android ¯\(ツ)/¯