我应该用什么替换SCREEN_DIM_WAKE_LOCK? [英] What should I replace SCREEN_DIM_WAKE_LOCK with?

查看:256
本文介绍了我应该用什么替换SCREEN_DIM_WAKE_LOCK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用以下引用的代码来进行警报通知活动的唤醒锁定.但是, SCREEN_DIM_LOCK 已弃用.那么,我应该用它代替什么?

I am currently utilizing the below referenced code for a wake lock on an alarm notification activity. However, SCREEN_DIM_LOCK has been depreciated. So, what should I be replacing it with?

//Instance of wake lock for AlarmActivity
PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "MyWakeLock");

推荐答案

Android开发者文档指定将 SCREEN_DIM_WAKE_LOCK 替换为 FLAG_KEEP_SCREEN_ON .经过一番挖掘之后,我打开了这个...

Android Developer documentation specifies that SCREEN_DIM_WAKE_LOCK should be replaced with FLAG_KEEP_SCREEN_ON. After doing a bit of digging, I turned up this...

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

应将其放在 onCreate()方法中.

这篇关于我应该用什么替换SCREEN_DIM_WAKE_LOCK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆