Android Oreo Allows Apps to Read USSD Messages from Carriers

We may earn a commission for purchases made using our links.

The USSD is a protocol for sending data through GSM, similar to SMS. It’s most commonly used for callback services, checking data/minutes, interactive news, ringtone selling, and even payment methods. It’s a bare-bones service that’s available universally in smartphones and feature phones alike, and its reliability is the main reason why USSD hasn’t changed one bit since GSM was first implemented in 1991. While they have been always present in any Android dialer app, USSD messages always appear as a dialog or basic, system themed menus. No other apps could interact with these USSD messages, at least until now.

With Android Oreo, a new class has been added that allows apps to interact with USSD requests. The TelephonyManager.UssdResponseCallback class is used to notify callers of sendUssdRequest when the network successfully completes a USSD request or if there was a failure while completing the request. In these cases, onReceiveUssdResponse will be called if the request was successfully completed and onReceiveUssdResponseFailed will be called if the request fails.

While the system will still manage all USSD messages with the existing implementation, this should be a starting point for app developers to start interacting with USSD requests. And considering that in previous Android versions the only way to read USSD messages was to implement a performance-heavy Accessibility Service to read all window content, this new API is now a much more clean way of accessing these messages.

There is currently no replacement for the USSD protocol, and given how much information your carrier offers about your mobile plan through USSD codes, this new API will find great use in the future. For instance, reading USSD code responses offer much more accurate information about your current data plan than Android’s native data reporting system. That’s because the native system can’t take into account some nuances such as T-Mobile’s Binge-On feature.

You can check out the documentation and the usage for this class at the Android Developers website, so you can start tinkering with it and deploy it on your app. Android Oreo has introduced lots of small but significant new, non-advertised changes and API, and we’ll keep you informed on anything else we find.