简体   繁体   English

Android - 在我的应用中禁用接近传感器

[英]Android - Disable proximity sensor in my app

I'm working on an app that allows the user to start a phone call from the app itself and once the call was initiated, the user can get back to the app to do some UI actions. 我正在开发一个应用程序,允许用户从应用程序本身开始拨打电话,一旦调用启动,用户就可以返回应用程序进行一些UI操作。

My current problem is that once the call started the proximity sensor was enabled which makes it almost impossible to work with the app (depends on the sensitivity of the sensor - per device). 我目前的问题是,一旦呼叫启动,接近传感器被启用,这使得几乎不可能使用应用程序(取决于传感器的灵敏度 - 每个设备)。

Is there anyway to control the sensor? 反正有控制传感器吗? For example, I would like to disable the sensor once my activity is visible and re-enable it once invisible. 例如,我想在活动可见后禁用传感器,并在隐形后重新启用它。

Thanks, Lior. 谢谢,Lior。

Try to set WakeLock in your application code...like below.... 尝试在应用程序代码中设置WakeLock ...如下所示....

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK, "FullWakeLock" );

Hope it will help you... 希望它能帮到你......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM