App Inventor Extensions


Phone State Listener Extension

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension or bug reports please start a new thread in the App Inventor community. Thank you.

For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.

Oct 12th, 2025: Version 1: initial version.

Description

The phonecall component stops listening after closing the app. Therefore I prepared the PhoneStateListener extension, which is able to listen to phone state changes of your device also if your app is not running. The itoox-wrapper library from Kumaraswamy is used, which helps to directly invoke Itoo (if present) to call procedures from the background.
Required permissions: android.permission.READ_PHONE_STATE, android.permission.READ_CALL_LOG

Properties


Dummy property to display the action helper blocks. The action helper blocks can be used in the OnReceive event handler.


Reference screen for Itoo where the procedure 'OnPhoneStateChanged' exists. It is advised to set the Reference screen property before Starting the service initially. Or if no property is set, the extension will take "Screen1" as the reference by default.

OnPhoneStateChanged has the arguments action, number, start and end.

Methods


Ask for permissions android.permission.READ_PHONE_STATE and android.permission.READ_CALL_LOG


Returns true, if permissions have been granted, else false.


Enables the BroadcastReceiver to start monitoring call state changes.


Disables the BroadcastReceiver to stop monitoring call state changes.


Checks if the BroadcastReceiver is currently enabled (listening) or disabled. Returns true if the BroadcastReceiver is listening, else false.

Example App "Phone State Listener Test"

In the example app the phone state listener extension stores all phone state changed events using the itoo StoreProperty method and displays the log after starting the app.



Test

Tested successfully on Samsung Galaxy A54 running on Android 15.

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Download


Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to donate a small amount!

Donation amount:

or donate some mBTC to Bitcoin Address:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Bitcoin

Thank you! Taifun
 

Download TaifunPhoneStateListener extension (aix file
Download Phone State Listener Test project (aia file)
Back to top of page ...

Creative Commons License
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.

Back to top of page ...


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact