How to read/intercept USSD message coming on Andro

2019-02-13 19:05发布

问题:

So unil this point all I can figure over was that until Android 4.2.2 there were two ways available to us :

  1. Use the logcat and extract information from it Runtime.getRuntime().exec( "logcat -v time -b main PhoneUtils:D"); I used this code to read the logcat and find out the displayMMIComplete message here

  2. Use the provided intent named com.android.ussd.IExtendedNetworkService and listen for this intent and do you task.

So what I've acknoweldge until now is, Since 4.0 onwards this intent has been removed and since 4.2.2 onwards printing of USSD message info in the logcat has been removed?

Am I right until here? And secondly what's the hack or solution now to read the USSD message, there must be some way we can get through it?

回答1:

There is no Android-framework provided API yet which can be used to "read/intercept" USSD Messages in a Portable way.

The 2 approaches that you mentioned is what was available till now, but as you mentioned, support for it is dropped from Android open source project.

There is a request/discussion going on, which clearly shows that many developers are requesting this feature, but so far there is no update/communication from Google's side to explain future roadmap about adding support to "read/intercept" USSD Messages in a Portable way.