每当收到来电或短信时,我都会尝试关闭手电筒。 它在某些设备(即HUAWEI设备)中运行良好 当我拒绝来电时,我的闪光灯不会熄灭。
相关代码:
else{
if(phoneManager.getCallState() == TelephonyManager.CALL_STATE_RINGING){
if(prefs.getBoolean("call", true)) {
Log.e("call", "start -> type:" + prefs.getString("type", ""));
String tp = prefs.getString("flash_type", "");
if(!tp.equals(""))
flash.startCallFlashLight(getIndex(tp));
else
flash.startCallFlashLight(1);
lastState = TelephonyManager.CALL_STATE_RINGING;
}
}
else if(lastState == TelephonyManager.CALL_STATE_RINGING &&
( phoneManager.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK ||
phoneManager.getCallState() == TelephonyManager.CALL_STATE_IDLE)) {
Log.e("call", "stop");
flash.stopCallFlashLight();
lastState = -1;
}
}