App Inventor Extensions


Telephony Manager 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.

Jan 30th, 2016: Version 1: initial version for App Inventor version ai2extensions6 and Companion version 235.cdk2.

Feb 10th, 2016: Version 2: CellId and LAC added.

Feb 13th, 2016: Version 3: SignalStrengthChanged event added.

Mar 07th, 2016: Version 4: SignalStrength properties added.

Apr 05th, 2016: Version 5: LTE for methods CellId and Lac added.

Aug 11th, 2016: Version 5a: avoid DX execution failed error: build each extension separately

Feb 10th, 2019: The example projects have been updated using the new permission blocks and now work with the SDK 26 requirements.

Jul 26th, 2019: Version 6: SignalStrengthChanged, SignalStrengthDbm and SignalStrengthAsu now work also for WCDMA, CDMA and LTE, however these blocks now needs permission android.permission.ACCESS_COARSE_LOCATION. New method Network Type and new methods to start and stop Signal Strength Listener added

Oct 13th, 2020: Version 7: bugfix: Attempt to invoke method 'java.util.iterator java.util.List.iterator()" on a null object reference
bugfix: java.lang.ClassCastException: android.telephony.CellInfoLte cannot be cast to android.telephony.CellInfoGsm
API29 update: DeviceID and SimSeriaNumber do not return values anymore starting from Android 10 (API Level 29),
android.permission.ACCESS_FINE_LOCATION now required for CellId starting from API Level 29 (Android 10)

March 23th, 2023: Version 8: SDK31 update: new permission READ_PHONE_NUMBERS, getNetworkType changed to getDataNetworkType. Google deprecated functionality starting from API31. Therefore the corresponding methods and events have been removed from the extension: properties: SignalStrengthAsu and SignalStrengthDbm, methods: StartSignatStrengthListener, StopSignalStrengthListener, CellId and Lac, events: SignalStrengthChanged.
Note: this version of the extension is not compatible with earlier versions. You therefore have to remove the extension from your project and then import it as new extension.

August 29th, 2023: Version 9: LteSignalStrength method added, CallStateListener method and corresponding CallStateChanged event added.

January 7th, 2024: Version 10: CallStateListener removed and CallStateChanged event removed as not compatible with all devices; fix for tablets, which do not offer phone capabilities, new method PhoneType

Description

Extension to get some information from the telephony manager.
Required permission: android.permission.READ_PHONE_STATE, android.permission.READ_PHONE_NUMBERS
Minimum API level is 18!
Thank you Niki Romagnoli for your snippet to provide country code from phone code and vice versa.
Required permissions: android.permission.READ_PHONE_STATE or android.permission.READ_PHONE_NUMBERS depending on the Android version of the device, ACCESS_COARSE_LOCATION for LteSignalStrength method added. See the example project below about how to ask fo the required permissions!

Methods


Returns the API Level of the device.


Returns the IMEI/MEID of the device.
If the device is a GSM device then IMEI will be returned and if the device is a CDMA device then MEID will be returned. In case of tablets or devices which can't act as Mobile Phone, IMEI will be null.

Note: Starting from android 10 this method unfortunately no longer returns the id, see also this thread in the App Inventor community. The default value "unavailable for this device" will be returned in this case.


Return the device phone number (MSISDN).
Thank you Tanja for being the sponsor of this block!

Note: In case of tablets or devices which can't act as Mobile Phone, phone number will be null.

Note: For dual SIM cards the preferred SIM details are returned. Thank you mannankhanabdul!

Note: This is no guaranteed solution, because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. As workaround you always can use this solution.


Returns the phone type of the device. Possible values: Tablet or Mobile.


Return the registered network operator's two-chars country code. In case of tablets or devices which can't act as Mobile Phone, this will be null.


Return the MCC + MNC of the registered network operator. In case of tablets or devices which can't act as Mobile Phone, this will be null.


Return the registered network operator's name. In case of tablets or devices which can't act as Mobile Phone, this will be null.


Return the SIM operator's two-chars country ISO code. In case of tablets or devices which can't act as Mobile Phone, this will be null.


Return the SIM operator's MNC + MCC number. In case of tablets or devices which can't act as Mobile Phone, this will be null.


Return the SIM Serial Number. In case of tablets or devices which can't act as Mobile Phone, this will be null.
Note: This method will not work anymore for Android devices running on Android 10 or later, for details see this thread. The default value "unavailable for this device" will be returned in this case.


Get phone code from two-chars country ISO code. For example country=US provides 1, country=IT provides 39. The country ISO code will automatically be converted into upper case.
Thank you Tanja for being the sponsor of this block!


Get list of two-chars country ISO codes from phone code. Several countries may match the same code.


Return the network type for the current data connection. Possible values: 1xRTT, CDMA, EDGE, EHRPD, EVDO_0, EVDO_A, EVDO_B, GPRS, GSM, HSDPA, HSPA, HSPAP, HSUPA, IDEN, IWLAN, LTE, TD_SCDMA, UMTS, UNKNOWN. NR will be available starting from API 29.


Get LTE Signal Strength. This method is available starting from Android 10, for older devices 0 will be returned.

Example Use


Questions and Answers

Q1: Your extension works nicely - thank you. But when I went to install the .apk, Android gave all these warnings - -like - - "needs permission to access your device id, your phone number your SIM ..." so I deleted the extension and used TINYDB instead to store a USERID. But now when I install the .apk Android says "it will gain access to: modify or delete the contents of your SD card". Maybe if your extension only accessed the DEVICEID, android would only caution "access to device id"? If that is so then I'm interested in an extension that does ONLY THAT.
A: The phonemanager extension requires the permission: READ_PHONE_STATE. It is not possible to restrict this more in detail.

Q2: I've used the Telefony Manager Extension in my app, but when I install it for the first time, it doesn't ask for the phone permission and the app shows the following error message: Runtime Error getDeviceID. Neither user 10316 not current process has android.permission.READ_PHONE_STATE or android.permission.READ_SMS.
A: See the example projects about how to use the new permission blocks to ask for the required permissions!

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

Terms and Conditions

  • Have fun and use this extension in your App Inventor projects! Pura Vida!
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • This is is the only authorized place to download this extension. It is not allowed to host this extension somewhere else and offer it for others to download, be it on another website or market place or similar. The reason is, everybody should be able to have the opportunity to donate something in case you like my work. You are allowed to provide a link to this site, so others can download the extension here. You will find the most up to date version always here including documentation and usage examples. Thank you for your kind understanding.

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 TaifunTM extension (aix file)

Download Telephony Manager 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.


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