Android v4.2.2。我在试着阻止屏幕进入睡眠状态。我已经尝试了一些事情,比如更改数据库中的相关设置:
adb shell "sqlite3 /data/data/com.android.providers.settings/databases/settings.db \"update system set value='-1' where name='screen_off_timeout'\";"但这并不管用-- screen几乎立刻就睡着了。如果我转到设置应用程序,则没有禁用它的选项。取而代之的是,它的范围从15s到30m。
我还尝试在应用程序中设置KEEP_SCREEN_ON标志,但是当我切换到一个新的活动时,它停止工作。
还有什么我可以试试的吗?我希望db设置可以完成这项工作。这是我的系统数据库。也许我遗漏了一个可以插入的设置?
1|volume_music|11
2|volume_ring|5
3|volume_system|7
4|volume_voice|4
5|volume_alarm|6
6|volume_notification|5
7|volume_bluetooth_sco|7
8|mode_ringer_streams_affected|174
9|mute_streams_affected|46
10|vibrate_when_ringing|0
11|dim_screen|0
13|dtmf_tone_type|0
14|hearing_aid|0
15|tty_mode|0
16|screen_brightness|102
17|screen_brightness_mode|0
18|window_animation_scale|1.0
19|transition_animation_scale|1.0
20|accelerometer_rotation|1
21|haptic_feedback_enabled|1
22|notification_light_pulse|1
23|dtmf_tone|1
24|sound_effects_enabled|1
26|lockscreen_sounds_enabled|1
27|pointer_speed|0
28|next_alarm_formatted|
29|alarm_alert|content://media/internal/audio/media/5
30|notification_sound|content://media/internal/audio/media/7
31|ringtone|content://media/internal/audio/media/9
32|volume_music_headset|10
33|volume_music_last_audible_headset|10
34|volume_music_headphone|10
35|volume_music_last_audible_headphone|10
36|time_12_24|24
37|date_format|dd-MM-yyyy
39|stay_on_while_plugged_in|1
45|screen_off_timeout|-1发布于 2017-08-27 16:40:55
您的设置数据库包含系统设置的默认超时,它可能很低,因此由于超时值较低,设备立即进入睡眠状态。您可以发出adb shell命令来增加屏幕超时。
adb shell settings put system screen_off_timeout 60000注意: 60000 =1分钟
您还可以使用所需的超时更新设置db,然后将db推送回设备,但它需要root用户。上述命令不需要对设备进行根操作。
发布于 2013-12-02 22:26:31
这与Activity有关,没有来自DB的影响。只需将android:keepScreenOn="true"添加到xml中的layout
发布于 2013-12-02 22:23:54
你试过这个吗?
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
wl.acquire();有关更多信息,请访问此链接http://thiranjith.com/2012/02/22/android-prevent-screen-timeout/
https://stackoverflow.com/questions/20330518
复制相似问题