本文整理汇总了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();
}