I ran into an issue with Android 6.0. Marshmallow was loaded to a Nexus 6 from the official Nexus factory firmware image site (https://developers.google.com/android/nexus/images).
I have an app where I use AlarmManager to start an activity that disables keyguard so the activity can be visible even if the phone is locked (like an alarm clock app does). In this activity if the user clicks on a button then it opens a dialog where the user should type in an EditText view. When the dialog shows or the user clicks on the EditText it should open the keyboard. This has been working until now and seems to be working on every OS version except 6.0 on my Nexus 6.
I suspect that the reason is that the phone is locked when the Activity starts as if I start the Activity when the phone is unlocked then the keyboard shows perfectly. This seems to only happen on 6.0.
Can anyone confirm this or let me know if something has changed in 6.0 that I'm not aware of?
Thanks.
Android keyguard manages the device and work challenge lock screens. This policy lets you manage features for Android Enterprise work profile keyguard and advanced device keyguard. You can control: Keyguard management on work profile devices.
Press and hold volume down + power button for at least 8 seconds. That will reboot your device and hopefully correct the keyboard not appearing. Press and hold volume down + power button for at least 8 seconds. That will reboot your device and hopefully correct the keyboard not appearing.
Keyguard basically refers to the code that handles the unlocking of the phone. it's like the keypad lock on your nokia phone a few years back just with the utility on a touchscreen. you can find more info it you look in android/app or com\android\internal\policy\impl.
Finally I found a working solution. Dialog windows seem to have their own flags in Marshmallow which have to bet set. I did it in AlertDialog like this:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("My Title");
// Add other stuff for AlertDialog here
AlertDialog alertDialog = builder.create();
alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
alertDialog.show();
For my PreferenceActivity
I had to extend the EditTextPreference
in order to solve the issue and then use myappname.TextPref
instead of EditTextPreference
in the XML config file.
class TextPref extends EditTextPreference {
public TextPref(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void showDialog(Bundle state) {
super.showDialog(state);
Dialog dialog = getDialog();
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With