Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android check has telephone call active [duplicate]

How to check if a telephone call is currently active from a non-telephone app?

What API do I need to detect this?

like image 508
linquize Avatar asked Jul 02 '13 06:07

linquize


People also ask

What is ongoing call on android?

"Ongoing" suggests that the call is currently in session, which has caused me to check my phone connection quite a few times to make sure that I do not have an open line.

What is Android studio call?

We are able to make a phone call in android via intent. You need to write only three lines of code to make a phone call. Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:"+8802177690));//change the number.

How can I get call state in Android?

We can also get the information of call state using the TelephonyManager class. For this purpose, we need to call the listen method of TelephonyManager class by passing the PhonStateListener instance. The PhoneStateListener interface must be implemented to get the call state.


1 Answers

try this:

public boolean isCallActive(Context context){
   AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
   return manager.getMode() == AudioManager.MODE_IN_CALL;
}
like image 97
Tarek Hallak Avatar answered Oct 13 '22 00:10

Tarek Hallak