Unlock and unlock the screen of an Android phone when compiling and starting a project?

When you create and launch an iOS application using Xcode, the phone starts to stay awake and the application starts. Is there a way to wake and unlock the screen of an Android phone (or tablet) and then run the installed Android application (Eclipse, Android Studio)?

+4
source share
3 answers

The best and easiest solution is to use the option (in the development section) that the screen will never go blank. My name is "Stay awake". This option prevents the phone from locking when a USB cable is connected.

+2
source

: :

    if (BuildConfig.DEBUG) {
        // These flags cause the device screen to turn on (and bypass screen guard if possible) when launching.
        // This makes it easy for developers to test the app launch without needing to turn on the device
        // each time and without needing to enable the "Stay awake" option.
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    }

:

  • ,

, , / . (, "" ), , , .

: / , if (BuildConfig.DEBUG),

+10

You cannot unlock and wake the phone, as it will not be very safe, however you can enable "Stay in battle" in the developer’s settings.

0
source

Source: https://habr.com/ru/post/1531221/


All Articles