0

My question is, what is the best way to get the phone state (is it in call mode), to decide the further way. I would like to check for phone state before deciding whether execute sound notification or not. If I understood right the TelephonyManager requires a BroadcastReceiver so app can detect when the phone state has changed. But in my app I want to check phone state in one discreet moment.

Kara
  • 6,115
  • 16
  • 50
  • 57
aphelion
  • 561
  • 1
  • 5
  • 12

1 Answers1

1

I don't think there's a best way because there is only one way, check the call state via TelephonyManager. No need for a receiver:

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
int callState = tm.getCallState(); 

See this for the call state constants.

fweigl
  • 21,278
  • 20
  • 114
  • 205
  • Thanks for answer! However i just realised that in my case i want to check not only the phone state, but also if any other speaker-to-ear processes are active (skype etc). – aphelion Apr 11 '13 at 13:54