Skip to content

Commit

Permalink
Android: fixing method not found "isDeviceLocked" on older devices (#430
Browse files Browse the repository at this point in the history
)
  • Loading branch information
scottrules44 authored Jul 30, 2022
1 parent db2c64d commit 49fa898
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions platform/android/sdk/src/com/ansca/corona/SystemMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,14 @@ public boolean isScreenOff() {
public boolean isScreenLocked() {
android.app.KeyguardManager keyguardManager;
keyguardManager = (android.app.KeyguardManager)fContext.getSystemService(android.content.Context.KEYGUARD_SERVICE);
return keyguardManager.isDeviceLocked();
//Use new/updated method if supported
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
return keyguardManager.isDeviceLocked();
}else{
return keyguardManager.inKeyguardRestrictedInputMode();
}

}

/**
* Determines if the screen is currently unlocked and allows user interaction.
* @return Returns true if screen is unlocked. Returns false if screen is locked or powered off.
Expand Down

0 comments on commit 49fa898

Please sign in to comment.