WEB开发网
开发学院手机开发Android 开发 让Android设备永不锁屏 阅读

让Android设备永不锁屏

 2010-07-15 21:21:00 来源:WEB开发网   
核心提示:/*** External apps (like the phone app) can tell us to disable the keygaurd.*/private boolean mExternallyEnabled = true;mExternallyEnabled是用来管理是否开启屏幕锁的关键,默认值是打开

/**

* External apps (like the phone app) can tell us to disable the keygaurd.

*/

private boolean mExternallyEnabled = true;

mExternallyEnabled是用来管理是否开启屏幕锁的关键。默认值是打开屏锁,根据注释可以知道他是希望应用程序来修改这个值。但是经过加打印信息发现开机的时候没有任何应用程序会修改它。修改这个值调用如下函数:

/**

* Same semantics as {@link WindowManagerPolicy#enableKeyguard}; provide

* a way for external stuff to override normal keyguard behavior. For instance

* the phone app disables the keyguard when it receives incoming calls.

*/

public void setKeyguardEnabled(boolean enabled) {

synchronized (this) {

if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")");

mExternallyEnabled = enabled;

if (!enabled && mShowing) {

if (mExitSecureCallback != null) {

if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring");

// we're in the process of handling a request to verify the user

// can get past the keyguard. ignore extraneous requests to disable / reenable

return;

}

// hiding keyguard that is showing, remember to reshow later

if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, "

+ "disabling status bar expansion");

mNeedToReshowWhenReenabled = true;

hideLocked();

} else if (enabled && mNeedToReshowWhenReenabled) {

// reenabled after previously hidden, reshow

if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling "

+ "status bar expansion");

mNeedToReshowWhenReenabled = false;

if (mExitSecureCallback != null) {

if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");

mExitSecureCallback.onKeyguardExitResult(false);

上一页  1 2 3 4  下一页

Tags:Android 设备 永不

编辑录入:coldstar [复制链接] [打 印]
赞助商链接