本文整理匯總了Java中android.app.KeyguardManager.isKeyguardLocked方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyguardManager.isKeyguardLocked方法的具體用法?Java KeyguardManager.isKeyguardLocked怎麽用?Java KeyguardManager.isKeyguardLocked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.KeyguardManager
的用法示例。
在下文中一共展示了KeyguardManager.isKeyguardLocked方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceive
import android.app.KeyguardManager; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
//Log.d("Smarper-Features", "Got screen update");
featuresLock.lock();
try {
if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
currentFeatures.screenOn = true;
//Log.d("Smarper-Debug", "Screen became interactive");
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
currentFeatures.screenOn = false;
//Log.d("Smarper-Debug", "Screen became not interactive");
//Update locked state:
currentFeatures.screenLocked = km.isKeyguardLocked();
//Log.d("Smarper-Debug", "Screen is locked: " + currentFeatures.screenLocked);
} else { //ACTION_USER_PRESENT, i.e. screen is unlocked
currentFeatures.screenLocked = false;
// Log.d("Smarper-Debug", "Screen unlocking");
}
} finally {
featuresLock.unlock();
}
}
示例2: isKeyguardUp
import android.app.KeyguardManager; //導入方法依賴的package包/類
public boolean isKeyguardUp() {
KeyguardManager km = (KeyguardManager) this.context.getSystemService(Context.KEYGUARD_SERVICE);
return km.inKeyguardRestrictedInputMode() || km.isKeyguardLocked();
}
示例3: isLocked
import android.app.KeyguardManager; //導入方法依賴的package包/類
/**
* Checks the lock state of the device.
*
* @return <code>true</code> if the device is in locked state and <code>false</code> otherwise.
*/
private boolean isLocked() {
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager.isKeyguardLocked();
}