Reputation: 1607
I'm mainly using the Android emulator for development. Is there a quick way (ideally a keyboard shortcut) to switch between dark mode and light mode for testing the dark/light themes?
Upvotes: 11
Views: 4102
Reputation: 136
pavelperc's answer doesn't work if you have multiple devices running. You can adjust the script to toggle dark mode for all running devices as follows (based on this answer):
alias adb="/Users/YOUR_USERNAME/Library/Android/sdk/platform-tools/adb"
for device in `adb devices | awk '{print $1}'`; do
if [ ! "$device" = "" ] && [ ! "$device" = "List" ]
then
adb -s $device $@
if [[ $(adb -s $device shell "cmd uimode night") == "Night mode: yes" ]]; then
adb -s $device shell "cmd uimode night no"
else
adb -s $device shell "cmd uimode night yes"
fi
fi
done
Upvotes: 0
Reputation: 399
If you use MacOS, you can automate this action with a shortcut:
alias adb="/Users/YOUR_USERNAME/Library/Android/sdk/platform-tools/adb"
if [[ $(adb shell "cmd uimode night") == "Night mode: yes" ]]; then
adb shell "cmd uimode night no"
else
adb shell "cmd uimode night yes"
fi
Here is an example:
Works perfectly!
Upvotes: 15
Reputation: 481
Just to bring more visibility to the comment above with a great solution:
You should be able to add the dark mode tile in the [swipe down] notification shade, as you do with an actual device.
Obviously it will change slightly depending on the phone you are emulating but here is a demo for anyone not used to Android devices
Upvotes: 10