且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与Android锁在自定义锁屏应用程序问题

更新时间:2023-02-13 14:13:10

键盘锁相关的逻辑的行为可以从设备而异。这是因为lockscreens往往是定制的由设备制造商(即不是股票),其中一些尊重你使用键盘锁逻辑,有些则没有。

The behavior of keyguard-related logic can vary from device to device. That's because lockscreens are often custom-made by device manufacturers (i.e. not stock), some of them respect the keyguard logic you use, some don't.

此外,AFAIK较新的方式来控制键盘锁是使用的窗口标志:

Also, afaik the newer way to control keyguard is to use window flags:

// inside activity
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
        | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

这不会解决问题,但,设备仍然有他们说的这一点。

This will not solve the problem though, devices still have their say about this.

例如。从我的经验,Galaxy Nexus的将显示上述键盘保护您的活动的窗口,但不会关闭它(你会认为谷歌品牌的设备应该尊重国旗,EH),所以,如果你打你的活动后退按钮 - 你会得到标准的锁屏---而HTC One X的,似乎要妥善处理好辞退部分:你的活动窗口将导致标准锁屏得到解雇预期

E.g. from my experience, Galaxy Nexus will show your activity's window above keyguard but will not dismiss it (you'd think Google-branded device should respect the flag, eh), so if you hit the back button in your activity - you'll get standard lockscreen --- while HTC One X seems to handle the dismiss part properly: your activity window will cause standard lockscreen to get dismissed as expected.

我发现没有办法强迫所有设备可​​正常使用。 Android的API并不意味着可以创建自定义锁屏(未至少目前)。看看那些在商店 - 他们都没有被足够稳定的完全相同的问题

I found no way to force all devices to behave properly. Android API is not meant to enable you to create custom lock screens (at least not currently). Take a look at the ones in the store - they all have the exact same problem of not being stable enough.

由于戴安娜Hackborn 说,在这个谷歌论坛回答,任何你能在这方面做的是一个黑客这样期待它不时打破时间。

As Dianne Hackborn says in this Google Groups answer, anything you can do in this regard is a hack so expect it to break from time to time.