简体   繁体   中英

how to keep android display from sleeping or dimming while plugged in?

i have some nexus 7's (2013) that are not rooted and have api 6.0.1 with may security patches.

i have stay awake on in developer options. i have everything off under the display settings except for sleep (which can not be turned off and is set to 30 minutes). despite this, the tablet dims after about 30 minutes.

i tried acquiring and releasing wakelock in on resume and on pause with no joy.

adb shell settings put global stay_on_while_plugged_in 0 - does not work either (neither does a value of 7 - the original value was 3)

Here is the google documentation: https://developer.android.com/training/scheduling/wakelock.html

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}

只是获取清单文件中的wake_lock权限对我有用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM