2

We are developing an app which needs to interact with various opperators USSD menus. (USSD is GSM's Unstructured Supplementary Service Data). I have searched and searched for a solution to no avail. It may not be possible.

We need to be able to initiate a ussd session, e.g. dial *150*00#

Phone receives USSD response - ideally we hide or automate a response immediately so it simply flashes in and out.

We automate a response, and more often a series of response, receive, response until complete.

The app then scrapes in the automated sms received.

This needs to work ideally for android versions pre oreo and post, so I presume using accessibility services pre and the ussd api post. API 26 seems to work ok for a 1 step receive response but from what I read not for multiple steps.

Any help most appreciated.

jww
  • 97,681
  • 90
  • 411
  • 885
Pejt2000
  • 21
  • 1
  • 3
  • 1
    Possible duplicate of [How is it possible to do USSD requests on Android?](https://stackoverflow.com/q/5477597/608639) – jww Oct 07 '18 at 01:57

1 Answers1

4

You can use this library for multi step ussd https://github.com/romellfudi/VoIpUSSD. It leverages accessability service for scraping, filling and dismissing ussd dialogs

Say you want to perform this ussd sequence *122# -> 1 -> final result

This is how you can do it

USSDApi ussdApi = USSDController.getInstance(context);
ussdApi.callUSSDInvoke("*122#", map, new USSDController.CallbackInvoke() {
    @Override
    public void responseInvoke(String message) {
        // message has the response for *122#
        ussdApi.send("1", new USSDController.CallbackMessage(){
            @Override
            public void responseMessage(String message) {
                // message has the response for 1
            }
        });
    }

   @Override
    public void over(String message) {
       // message contains the final result
    }
});
ducaale
  • 637
  • 6
  • 17