资源描述:
《android解除屏幕锁的方法》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第一个方法:窗体顶端窗体底端Android修改源代码控制永不锁屏锁定屏幕对于移动终端来说是非常有必要的,但是对于机顶盒产品就没有这个必要了。所以本文介绍一下怎样让Android设备永不锁屏。Android系统的锁屏时间存放在Setting数据库中,字段为Settings.System.SCREEN_OFF_TIMEOUT。查看SettingsProvider源码,查看如下文件的源码:frameworks/base/packages/SettingsProvider/src/com/Android/providers/settings/DatabaseHelper.java
2、查看loadSystemSettings()函数的代码如下:privatevoidloadSystemSettings(SQLiteDatabasedb){SQLiteStatementstmt=db.compileStatement("INSERTORIGNOREINTOsystem(name,value)"+"VALUES(?,?);");Resourcesr=mContext.getResources();loadBooleanSetting(stmt,Settings.System.DIM_SCREEN,R.bool.def_dim_screen);loadSet
3、ting(stmt,Settings.System.STAY_ON_WHILE_PLUGGED_IN,"1".equals(SystemProperties.get("ro.kernel.qemu"))?1:0);loadIntegerSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,R.integer.def_screen_off_timeout);//SetdefaultcdmaemergencytoneloadSetting(stmt,Settings.System.EMERGENCY_TONE,0);//Setdefa
4、ultcdmacallautoretryloadSetting(stmt,Settings.System.CALL_AUTO_RETRY,0);//SetdefaultcdmaDTMFtypeloadSetting(stmt,Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,0);//SetdefaulthearingaidloadSetting(stmt,Settings.System.HEARING_AID,0);//SetdefaultttymodeloadSetting(stmt,Settings.System.TTY_MOD
5、E,0);loadBooleanSetting(stmt,Settings.System.AIRPLANE_MODE_ON,R.bool.def_airplane_mode_on);loadStringSetting(stmt,Settings.System.AIRPLANE_MODE_RADIOS,R.string.def_airplane_mode_radios);loadStringSetting(stmt,Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS,R.string.airplane_mode_toggleabl
6、e_radios);loadBooleanSetting(stmt,Settings.System.AUTO_TIME,R.bool.def_auto_time);//SynctimetoNITZloadIntegerSetting(stmt,Settings.System.SCREEN_BRIGHTNESS,R.integer.def_screen_brightness);loadBooleanSetting(stmt,Settings.System.SCREEN_BRIGHTNESS_MODE,R.bool.def_screen_brightness_automati
7、c_mode);loadDefaultAnimationSettings(stmt);loadBooleanSetting(stmt,Settings.System.ACCELEROMETER_ROTATION,R.bool.def_accelerometer_rotation);loadDefaultHapticSettings(stmt);stmt.close();}从代码中我们可以看出,假如Settings.System.SCREEN_OFF_TIMEOUT没有初始化的话(系统首次启动,这个字段肯定是没有初始化的),将会