我编写了一个基于接近传感器的应用程序,但我希望能够让用户能够更改传感器的灵敏度。 是否可以?如果是怎么办?
最佳答案
只需“实现 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;
}
}
关于android - 如何更改 Android 接近传感器灵敏度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9403351/