mobileoff on whensmart screen offoff是什么意思

Max Lee is the founder .
Max makes Android tutorials and review videos for people who want to get high on Android over at his
Latest Posts
CategoriesCategories
Select Category
4K Cinematic Test
Android Accessories
&&&Chromecast
&&&Google Home
Android Apps
&&&Android Games
&&&Android Wear Apps
&&&Camera Apps
&&&GoogleApps
&&&GPS Apps
&&&Keyboard Apps
&&&Launcher Apps
&&&Music Apps
&&&Root Apps
&&&Rooted Apps
Android Deals
Android Giveaways
Android HOWTOs
Android ROMs
Android Root
Android Root Guide
Android Rumors
Android Smartphone Comparison
Android Smartphone News
Android Smartphone Reviews
Android Smartphone Unboxing
Android Smartphones
&&&ASUS Zenfone Zoom
&&&Droid 3
&&&Droid Bionic
&&&Droid Razr
&&&Galaxy Nexus
&&&Galaxy Note
&&&Galaxy Note 2
&&&Galaxy Note 3
&&&Galaxy Note 4
&&&Galaxy Note 5
&&&Galaxy Note 7
&&&Galaxy Note Edge
&&&Galaxy S2
&&&Galaxy S3
&&&Galaxy S4
&&&Galaxy S4 Active
&&&Galaxy S5
&&&Galaxy S6
&&&Galaxy S6 Edge
&&&Galaxy S6 Edge Plus
&&&Galaxy S7
&&&Galaxy S7 Edge
&&&Google Pixel XL
&&&Honor 8
&&&HTC Evo 3D
&&&HTC Evo 4G LTE
&&&HTC Evo Design 4G
&&&HTC One
&&&HTC One M8
&&&HTC One M9
&&&HTC One X
&&&Huawei Mate 8
&&&Huawei P8 Lite
&&&Huawei P9
&&&LG Flex 2
&&&Moto X Pure
&&&Moto Z Force
&&&Nexus 4
&&&Nexus 5
&&&Nexus 5X
&&&Nexus 6
&&&Nexus 6P
&&&Nexus S 4G
&&&OnePlus One
&&&OnePlus Two
&&&Pixel XL
&&&Redmi Note 2
&&&Xperia Z Ultra
&&&Xperia Z5 Premium
&&&YotaPhone 2
&&&ZenFone 2
Android Smartwatches
&&&G Watch
&&&Galaxy Gear
&&&Gear Live
&&&Gear S2
&&&Huawei Watch
&&&LG Watch Urbane
Android Speakers
Android Tablet Apps
&&&Android Tablet Launcher Apps
Android Tablet News
Android Tablet Reviews
Android Tablet Unboxing
Android Tablets
&&&Amazon Fire HD
&&&Galaxy Note 10.1
&&&Galaxy Tab 7 Plus
&&&HP TouchPad
&&&Kindle Fire
&&&Lenovo Yoga Tablet 2 Pro
&&&Nexus 10
&&&Nexus 7
&&&Nexus 9
&&&Transformer Prime
Android USB
Disassembly
Google Glass
HighOnAndroid Drone Test
HighOnAndroid LUX Test
HighOnAndroid Show
HighOnAndroid SOT Test
My Camera Gear
Network Tests
&&&InFlight WiFi
Screen Repair
Smartphone Cases
Smartphone Test
USB Power Bank
Virtual Reality Glasses
&&&Gear VR
Join HighOnAndroid G+ Community!
High On Android Root Tutorials
For all our other root tutorials, see our
Follow Author on Google+
# of people that got HIGH on Android on this site since Oct. 2011 when the site opened:
October 10, 2016
June 28, 2016
May 17, 2016
February 24, 2016
February 22, 2016android: turn off screen when close to face - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.3 million programmers, just like you, helping each other.
J it only takes a minute:
My app allows the user to access their corporate voice mail. Normally, durring a phone call when the user holds the device up to their ear, the screen shuts off so they wont accidentally push buttons with their face. I would like to make my app do the same thing when the user is listening to their voice mail.
anyone know how to do this?
5,920174591
What you are seeing is the use of a proximity sensor. For devices that have one, you access it through .
599k8214241492
If you are allowed to look at open source code without causing yourself problems, check the source of the .
Specifically
From src/com/android/phone/PhoneApp.java:
//Around line 423
// Wake lock used to control proximity sensor behavior.
if ((pm.getSupportedWakeLockFlags()
& PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) != 0x0) {
mProximityWakeLock = pm.newWakeLock(
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
// Around line 1151
if (((state == Phone.State.OFFHOOK) || mBeginningCall)&& !screenOnImmediately) {
// Phone is in use!
Arrange for the screen to turn off
// automatically when the sensor detects a close object.
if (!mProximityWakeLock.isHeld()) {
if (DBG) Log.d(LOG_TAG, "updateProximitySensorMode: acquiring...");
mProximityWakeLock.acquire();
if (VDBG) Log.d(LOG_TAG, "updateProximitySensorMode: lock already held.");
// Phone is either idle, or ringing.
We don't want any
// special proximity sensor behavior in either case.
if (mProximityWakeLock.isHeld()) {
if (DBG) Log.d(LOG_TAG, "updateProximitySensorMode: releasing...");
// Wait until user has moved the phone away from his head if we are
// releasing due to the phone call ending.
// Qtherwise, turn screen on immediately
int flags =
(screenOnImmediately ? 0 : PowerManager.WAIT_FOR_PROXIMITY_NEGATIVE);
mProximityWakeLock.release(flags);
Additionally, if you look at the code for the PowerManager class, PROXIMITY_SCREEN_OFF_WAKE_LOCK is documented (but hidden) and should do what you want ( I am not sure which API level this works for, however ) -- but not in the table for some reason.
* Wake lock that turns the screen off when the proximity sensor activates.
* Since not all devices have proximity sensors, use
* {@link #getSupportedWakeLockFlags() getSupportedWakeLockFlags()} to determine if
* this wake lock mode is supported.
public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = WAKE_BIT_PROXIMITY_SCREEN_OFF;
If you aren't afraid of using a potential undocumented feature, it should do exactly what you need.
as of API level 21 (Lollipop) you can get proximity wake lock this just like that:
if(powerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, TAG);
wakeLock.setReferenceCounted(false);
return wakeL
then it is up to you to acquire and release the lock.
PowerManager#getSupportedWakeLockFlags was hidden, but now exists nomore. They have invented isWakeLockLevelSupported instead.
1,90611850
Probably you don't need it anymore but for the ones that are interested in code you could have a look at my SpeakerProximity project at
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
The week's top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabled扫描下载MIUI论坛APP
在线时间0 小时
积分 20, 距离下一级还需 30 积分
积分 20, 距离下一级还需 30 积分
screen hangs when try to switch simcard on or off. sim gets on or off in the background but the screens hangs and doesn't com out.
遇到的人越多,MIUI开发组会越关注
分享到微信朋友圈
打开微信,点击底部的“发现”,使用 “扫一扫” 即可将网页分享到我的朋友圈。
Copyright (C) 2016 MIUI
京ICP备号 | 京公网安备34号 | 京ICP证110507号java - Android Screen OFF / ON - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.3 million programmers, just like you, helping each other.
J it only takes a minute:
I need to get my screen turned on/off using SensorEventListener when
public final void onSensorChanged(SensorEvent event) {
if (event.values[0] == 0)
turnScreenOFF();
else if (event.values[0] == 5)
turnScreenON();
I have tried many sample code for it, but I can't get my screen turned ON again after it's turned OFF
There is the code to turn off the screen :
WindowManager.LayoutParams params = getWindow().getAttributes();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
params.screenBrightness = 0.0f;
getWindow().setAttributes(params);
For screen on-off state, you can try with ACTION_SCREEN_ON and ACTION_SCREEN_OFF intents,which will come in nifty if you’re making an application that might need to save state or respond to the user’s screen going to sleep/waking up, etc.
Check out the
Try out below:
private void unlockScreen() {
Window window = this.getWindow();
window.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
window.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
And call this method from onResume().
21.6k84079
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledandroid(125)
在做一个程序的时候,需要时刻保持某一服务是启动的,因此想到了通过监听屏幕SCREEN_ON和SCREEN_OFF这两个action。奇怪的是,这两个action只能通过代码的形式注册,才能被监听到,使用AndroidManifest.xml 完全监听不到。查了一下,发现这是PowerManager那边在发这个广播的时候,做了限制,限制只能有register到代码中的receiver才能接收。
那怎么才能保证我的服务一直是启动状态呢,其实还有另一个Action可以反映出用户正在使用手机的行为,每个用户在使用手机的时候,首先按电源键将屏幕点亮,紧接着就是解锁。解锁动作通过android.intent.action.USER_PRESENT发送出来,我们就能识别出该用户进入了home界面,也就能启动我们相应的服务了,不管你是要谈对话框welcome用户,还是后台启动程序升级服务,都可以!以神的名义发誓,该Action在AndroidManifest.xml中可以监听得到。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:72665次
积分:1336
积分:1336
排名:千里之外
原创:20篇
转载:299篇
(15)(3)(3)(7)(4)(12)(14)(17)(5)(26)(11)(7)(3)(1)(5)(1)(2)(3)(3)(4)(3)(3)(5)(8)(8)(2)(2)(2)(127)(16)

我要回帖

更多关于 intent.screenoff 的文章

 

随机推荐