Android tutorial - Android Call State - android app development - android studio - android development tutorial
Learn andriod - andriod tutorial - Android call - andriod examples - andriod programs
Definition of Call State:
- A decision block that checks the phone call state.
- If the proceed option is set to Immediately, then check if a call is currently in the state, or not, without pausing the fiber.
- If set to When changed, then the fiber will pause until a call has got to or left the state.
- 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.
- It provides one method onCallStateChanged().
Android Call State Example
- Let's see the example, where we are determining whether phone is ringing or phone is in a call or phone is neither ringing nor in a call.
activity_main.xml
- In this example, we don't have any component in this file.
Activity class
- Let's write the code to know the call state.
File: MainActivity.java
AndroidManifest.xml
- You need to provide READ_PHONE_STATE permission in the AndroidManifest.xml file.