Closed windmueller closed 9 years ago
That permission is deprecated since API 13. When I used the deprecated code the unlocking worked fine but locking (keyguardLock.reenableKeyguard()) didn't work at all. I tried using the recommended flags instead: getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
but even though it works the lock screen shows (flashes) for 0.1secs and then disappears every time an activity is shown. Very ugly. There is a bug related to this: https://code.google.com/p/android-developer-preview/issues/detail?id=1902 (have only tried with Nexus 5 so far so maybe it works on other phones).
I've tried on S4 running KitKat as well, same problem. The code I'm using is:
@Override
protected void onResume() {
super.onResume();
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean disableKeyguard = sharedPrefs.getBoolean(PrefsFragment.DISABLE_KEYGUARD, false);
if (disableKeyguard) {
try {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
} catch (SecurityException e) {
//kindle code goes here
}
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}
}
I know the locking probably should go in onPause or onStop. I will put it there if I get this to work.
What happens if you also use FLAG_KEEP_SCREEN_ON?
I never implemented this myself but I use several apps which are able to do this. e.g. Mighty Grocery. There are several examples on GitHub on how to use these flags, but I am unsure which of them just disable the keyguard.
Well, then it sounds like the idea rather is that the screen is kept on during the use of the app (meaning the lock screen will never even try to load), am I right? That is probably much easier (but was never in the initial request :P), but has the drawback that the screen is always on which will drain the battery faster.
I did try with that flag getting the same problem but then I manually triggered the screen lock by pressing the power button.
It was not in the initial request because I thought it would be possible without leaving the screen on. When I use Mighty Grocery while shopping, I turn off the screen manually. When I turn the screen back on, the keyguard is disabled.
"When I turn the screen back on, the keyguard is disabled."
That is how you want it right? (also meaning they have solved it, wonder how)
To be absolutely precise: When I turn on my phone while Beefcake is active, I do not want to have to unlock my phone. Instead, it should behave like I have no secure keyguard at all.
I don't know how to solve that. The current way is annoying (even though it works) since the lock screen flashes in the foreground every time a new activity starts. Perhaps it could be added anyway and you can test it out?
Of course, I can test this change. Do you want to implement it in a beta or should I install an APK manually?
We'll make a beta. Thanks again for your help!
Cheers On Jan 4, 2015 10:36 PM, "Stephan Windmüller" notifications@github.com wrote:
Of course, I can test this change. Do you want to implement it in a beta or should I install an APK manually?
— Reply to this email directly or view it on GitHub https://github.com/pambsoftware/beefcake/issues/1#issuecomment-68650156.
I tested the RC1, but it does not behave like expected.
The device still seems to be locked despite the fact that the lock screen is hidden. The screen flashes every time I switch to a new activity. But more interesting is the fact that the phone still behaves like it is locked, e.g. the screen timeout is very short.
I e-mailed the developer of Might Grocery and got a reply in 33min! :) He explained that they are using the deprecated API that I avoided on purpose. Perhaps the only way right now is to use it. I'll try.
Yeah, those guys have a really good support, I contacted them before, too. Waiting now for the next RC. :)
His advice solved it! :) Will come in RC2 tomorrow.
I would like a setting which allows Beefcake to disable the lockscreen of a device while the app is active, so I do not have to unlock the screen after each set. This can be done with the permission DISABLE_KEYGUARD.