2

I am trying to make the flashlight turn off whenever a call or SMS message is received. It works perfectly but in some devices (i.e. HUAWEI devices) my flash light doesn't turn off when I reject the incoming call.

Relevant code:

 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; } } 
8
  • if the code is working in most part of devices, please post stacktrace you have in the problematic ones Commented Jul 12, 2016 at 13:16
  • my logcat dont show anything Commented Jul 12, 2016 at 13:18
  • mmm... you mean anything strange, because android stacktrace is quite vervosing xD, you tried connecting problematic devices to the developing computer?? are the states updated correctly? Commented Jul 12, 2016 at 13:18
  • what is android stacktrace? is it part of my IDM to show my problem? Or you mean to debug this part of code? Commented Jul 12, 2016 at 13:20
  • which ide are you using? Eclipse? AndroidStudio? stackoverflow.com/questions/7841232/… Commented Jul 12, 2016 at 13:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.