如何改变安卓接近感应器的灵敏度? [英] How to change Android proximity sensor sensitivity?

查看:0
本文介绍了如何改变安卓接近感应器的灵敏度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个基于接近传感器的应用,但我希望能够让用户能够更改传感器的灵敏度。 有可能吗?如果是,应如何操作?

推荐答案

只需"实现SensorEventListener"并遵循代码:

public void onCallStateChanged(int state, String incomingNumber) {
        switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            System.out.println("My Call IDLE");
            CallState = false;
            StartAudioSpeacker();
            System.out.println("Is phone speaker : "+ audioManager.isSpeakerphoneOn());
            if (audioManager.isSpeakerphoneOn()) {
                audioManager.setSpeakerphoneOn(false);
                mSensorManager.unregisterListener(this);
            }
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            System.out.println("My Call OFFHOOK");
            CallState = true;
            StartAudioSpeacker();
            System.out.println("Is phone speaker : "+ audioManager.isSpeakerphoneOn());
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            System.out.println("My Call RINGING");
            break;
        }
    }

这篇关于如何改变安卓接近感应器的灵敏度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆