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 Extensions forum. 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

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

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

Description

Extension to get some information from the telephony manager.
Required permission: android.permission.READ_PHONE_STATE
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, android.permission.ACCESS_COARSE_LOCATION
See the example projects below about how to ask fo the required permissions!

Properties


Return the signal strength in asu. Works for GSM, WCDMA, CDMA and LTE.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.


Return the signal strength in dBm. Works for GSM, WCDMA, CDMA and LTE.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.

Methods


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: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


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

Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.
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.


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.
Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


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.
Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


Return the registered network operator's name. In case of tablets or devices which can't act as Mobile Phone, this will be null.
Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


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.
Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


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.
Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


Return the SIM Serial Number. In case of tablets or devices which can't act as Mobile Phone, this will be null.
Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.


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.

Note: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission. 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 base station cell id. In case the cell location is not available, 0 will be returned. For LTE, Android version must be min. Android 4.2 (API 17). The information provided is carrier dependent.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.
Thank you Seo for being the sponsor of this block!
Thank you Jose Juan for being the sponsor of the LTE enhancement of this block

Note: this method does not work for CDMA. Thank you qiutong ye.


Return the base station LAC. In case the cell location is not available, 0 will be returned. For LTE the Tracking Area Code will be provided, Android version must be min. Android 4.2 (API 17). The information provided is carrier dependent.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.
Thank you Jose Juan for being the sponsor of the LTE enhancement of this block

Note: this method does not work for CDMA. Thank you qiutong ye.


Start the listener.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.


Stop the listener.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.


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.

Events


Event indicating that signal strength has changed. Works for GSM, WCDMA, CDMA and LTE. Signal strength is provided in dBm and asu.

Make sure to start the listener before using this event.
Note: This block needs the permission ACCESS_COARSE_LOCATION. See the example project #2 below about how to ask for this permission.

Example Use #1


Example Use #2


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 forum.Thank you.

Terms and Conditions

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
 

Note: : There are currently issues in version 6 of the extension for network type LTE for some devices. I try to fix these issues. Meanwhile you can download version 5a.
Download TaifunTM extension (aix file) Version 5a
Download TaifunTM extension (aix file) Version 6

Download Telephony Manager Test 1 (aia file)
Download Telephony Manager Test 2 (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