91-9990449935 0120-4256464 |
Android Call State ExampleWe 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 ExampleLet'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.xmlIn this example, we don't have any component in this file.. Activity classLet's write the code to know the call state. File: MainActivity.java
AndroidManifest.xmlYou need to provide READ_PHONE_STATE permission in the AndroidManifest.xml file. File: AndroidManifest.xml
Output: |