Skip to content

Instantly share code, notes, and snippets.

@VadimCpp
Last active April 12, 2019 14:38
Show Gist options
  • Save VadimCpp/734542199ff92f4c82ff3e03174721d6 to your computer and use it in GitHub Desktop.
Save VadimCpp/734542199ff92f4c82ff3e03174721d6 to your computer and use it in GitHub Desktop.
How do I “shake” an Android device to bring up the dev menu to debug my React Native app

During the debugging react-native app on the Andoroid device I need to shake it every time to reload the app. There is a good article on StackOverflow on the topic: how-do-i-shake-an-android-device-bla-bla. Long story short, you can simply execute command in your terminal and avoid shaking real device:

adb shell input keyevent 82

Here I wanna create a shotcut for this long command. Create 'shake-android-device.sh' script:

#!/bin/bash

#
# See page for details:
# https://gist.github.com/VadimCpp/734542199ff92f4c82ff3e03174721d6
#

echo Shake an Android device
adb shell input keyevent 82

Make the script executable:

chmod a+x shake-android-device.sh

Put the script to the Scripts folder. Then open .bash_profile and create alias:

alias shake='~/Scripts/shake-android-device.sh'

Reload bash_profile:

source ~/.bash_profile

And simply type command:

shake

Voila!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment