Skip to content

Instantly share code, notes, and snippets.

What would you like to do?


How many times a day do you push code to your phone and then pick it up, press the power button to wake the device and then swipe to unlock? If you're like me that answer is probably hundreds!

By adding a couple of permissions to your src/debug/AndroidManifest.xml file and adding a helper class in src/debug/... that can be called from your activities, you can wakeup and unlock the device automatically when you push code to your phone.

<?xml version="1.0" encoding="utf-8"?>
<!-- Add this as a debug manifest so the permissions won't be required by your production app -->
<manifest xmlns:android="">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
public class BaseActivity extends Activity {
protected void onStart() {
// Wake the device and show our activity
if (BuildConfig.DEBUG) {
// Calling this from your launcher activity is enough, but I needed a good example spot ;)
import android.os.PowerManager;
import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.Context.POWER_SERVICE;
import static android.os.PowerManager.ACQUIRE_CAUSES_WAKEUP;
import static android.os.PowerManager.FULL_WAKE_LOCK;
import static android.os.PowerManager.ON_AFTER_RELEASE;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
* Add this to your application's src/debug/... sources
public class DebugUtils {
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
public static void riseAndShine(Activity activity) {
KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(KEYGUARD_SERVICE);
final KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("Unlock!");
PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, "Wakeup!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.