VOIP USSD ANDROID

Platform API License Workflow Gitter Bintray Bintray Kotlin Android Arsenal Jitpack

Loved the tool? Please consider donating πŸ’Έ to help it improve!

sponsor voip android library

Usage    |    Extra Features    |    Cordova Plugin    |    Contributors

### by Romell Dominguez [![](https://raw.githubusercontent.com/romellfudi/assets/master/favicon.ico)](https://www.romellfudi.com/) ## Target Development [High Quality](https://raw.githubusercontent.com/romellfudi/VoIpUSSD/Rev04/snapshot/device_recored.gif):

Jitpack

Interactive with ussd windoows, It is necessary to have present that the interface depends on the SO and on the manufacturer of Android device. ## Community Chat [![Gitter](https://img.shields.io/badge/gitter-join%20us-%23753a89.svg?&style=for-the-badge&logo=gitter&labelColor=ee1a67)](https://gitter.im/romellfudi/VoIpUSSD?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) ## Downloads Dashboard [![Data Studio](https://img.shields.io/badge/DATA%20STUDIO-DOWNLOADS%20REPORT-%23000000.svg?&style=for-the-badge&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDcuNDcgMTAwIj48ZGVmcz48c3R5bGU%2BLmNscy0xe2ZpbGw6IzY2OWRmMzt9LmNscy0ye2ZpbGw6IzFhNzNlODt9PC9zdHlsZT48L2RlZnM%2BPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNOTQuMDcsNzIuNzVINTVjLTkuNDYsMC0xNC43Myw2LjU5LTE0LjczLDEzLjYyQzQwLjIyLDkyLjc1LDQ0LjYyLDEwMCw1NSwxMDBoMzguOVY3Mi43NVoiLz48ZWxsaXBzZSBjbGFzcz0iY2xzLTIiIGN4PSI5NC4wNyIgY3k9Ijg2LjE1IiByeD0iMTMuNDEiIHJ5PSIxMy42MyIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTUzLjYzLDM2LjI2SDE0LjczQzUuMjcsMzYuMjYsMCw0Mi44NiwwLDQ5Ljg5YzAsNi4zNyw0LjQsMTMuNjMsMTQuNzMsMTMuNjNoMzguOVoiLz48ZWxsaXBzZSBjbGFzcz0iY2xzLTIiIGN4PSI1My42MyIgY3k9IjQ5Ljg5IiByeD0iMTMuNDEiIHJ5PSIxMy42MyIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTk0LjA3LDBINTVDNDUuNDksMCw0MC4yMiw2LjU5LDQwLjIyLDEzLjYzYzAsNi4zNyw0LjQsMTMuNjIsMTQuNzMsMTMuNjJoMzguOVYwWiIvPjxlbGxpcHNlIGNsYXNzPSJjbHMtMiIgY3g9Ijk0LjA3IiBjeT0iMTMuNjMiIHJ4PSIxMy40MSIgcnk9IjEzLjYzIi8%2BPC9zdmc%2B)](https://datastudio.google.com/reporting/3328e603-449b-4635-81a5-38e0abebafa4) ## USSD LIBRARY `latestVersion` is [![](https://img.shields.io/bintray/v/romllz489/maven/ussd-library.svg?style=flat-square&logo=jfrog)](https://bintray.com/romllz489/maven/ussd-library) `kotlinLatestVersion` is [![](https://img.shields.io/bintray/v/romllz489/maven/kotlin-ussd-library.svg?&style=flat-square&logo=jfrog)](https://bintray.com/romllz489/maven/kotlin-ussd-library) Add the following in your app's `build.gradle` file: ### From American Telcoms ```groovy repositories { jcenter() } dependencies { // java implementation 'com.romellfudi.ussdlibrary:ussd-library:{latestVersion}' // kotlin implementation 'com.romellfudi.ussdlibrary:kotlin-ussd-library:{kotlinLatestVersion}' } ``` ### From African Telcoms ```groovy repositories { maven { url 'https://jitpack.io' }// (jetpacking) } dependencies { // africa SNAPSHOT (jetpacking) // java implementation 'com.github.romellfudi.VoIpUSSD:ussd-library:africa-SNAPSHOT' implementation 'com.github.romellfudi.VoIpUSSD:ussd-library:alternative-SNAPSHOT' // kotlin implementation 'com.github.romellfudi.VoIpUSSD:kotlin-ussd-library:africa-SNAPSHOT' implementation 'com.github.romellfudi.VoIpUSSD:kotlin-ussd-library:alternative-SNAPSHOT' } ``` * Writing xml config file from [here](https://github.com/romellfudi/VoIpUSSD/blob/master/ussd-library/src/main/res/xml/ussd_service.xml) to res/xml folder (if necessary), this config file allow link between App and SO: ```xml <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" .../> ``` ### Application Puts dependencies on manifest, into manifest put CALL_PHONE, READ_PHONE_STATE and SYSTEM_ALERT_WINDOW: ```xml ``` Add service: ```xml java ``` ```xml kotlin ``` # How use: First you need an hashMap from detect witch USSD' response contains the login and error messages | KEY MESSAGE | String Messages | | ------ | ------ | | KEY_LOGIN | "espere","waiting","loading","esperando",... | | KEY_ERROR | "problema","problem","error","null",... | ```java map = new HashMap<>(); map.put("KEY_LOGIN",new HashSet<>(Arrays.asList("espere", "waiting", "loading", "esperando"))); map.put("KEY_ERROR",new HashSet<>(Arrays.asList("problema", "problem", "error", "null"))); ``` ```kotlin map = HashMap() map["KEY_LOGIN"] = HashSet(Arrays.asList("espere", "waiting", "loading", "esperando")) map["KEY_ERROR"] = HashSet(Arrays.asList("problema", "problem", "error", "null")) ``` Instance an object ussController with context ```java USSDApi ussdApi = USSDController.getInstance(context); ussdApi.callUSSDInvoke(phoneNumber, map, new USSDController.CallbackInvoke() { @Override public void responseInvoke(String message) { // message has the response string data String dataToSend = "data"// <- send "data" into USSD's input text ussdApi.send(dataToSend,new USSDController.CallbackMessage(){ @Override public void responseMessage(String message) { // message has the response string data from USSD } }); } @Override public void over(String message) { // message has the response string data from USSD or error // response no have input text, NOT SEND ANY DATA } }); ``` ```kotlin USSDApi ussdApi = USSDController.getInstance(activity) ussdApi.callUSSDOverlayInvoke(phoneNumber, map, object : USSDController.CallbackInvoke { override fun responseInvoke(message: String) { // message has the response string data var dataToSend = "data"// <- send "data" into USSD's input text ussdApi.send("1") { // it: response String // message has the response string data from USSD } } override fun over(message: String) { // message has the response string data from USSD or error // response no have input text, NOT SEND ANY DATA } }) ``` if you need work with your custom messages, use this structure: ```java ussdApi.callUSSDInvoke(phoneNumber, map, new USSDController.CallbackInvoke() { @Override public void responseInvoke(String message) { // first option list - select option 1 ussdApi.send("1",new USSDController.CallbackMessage(){ @Override public void responseMessage(String message) { // second option list - select option 1 ussdApi.send("1",new USSDController.CallbackMessage(){ @Override public void responseMessage(String message) { ... } }); } }); } @Override public void over(String message) { // message has the response string data from USSD // response no have input text, NOT SEND ANY DATA } ... }); ``` ```kotlin ussdApi.callUSSDOverlayInvoke(phoneNumber, map, object : USSDController.CallbackInvoke { override fun responseInvoke(message: String) { // first option list - select option 1 ussdApi.send("1") { // it: response response // second option list - select option 1 ussdApi.send("1") { // it: response message ... } } } override fun over(message: String) { // message has the response string data from USSD // response no have input text, NOT SEND ANY DATA } ... }) ``` for dual sim support ```java ussdApi.callUSSDInvoke(phoneNumber, simSlot, map, new USSDController.CallbackInvoke() { ... } ``` ```kotlin ussdApi.callUSSDOverlayInvoke(phoneNumber, simSlot, map, object : USSDController.CallbackInvoke { ... } ``` ## Static Methods In case use at android >= M, you could check previusly permissions, `callInvoke` and `callUSSDOverlayInvoke` methods check eneble too: ```java # check if accessibility permissions is enable USSDController.verifyAccesibilityAccess(Activity) # check if overlay permissions is enable USSDController.verifyOverLay(Activity) ``` ## Overlay Service Widget (not required) A huge problem working with ussd is you can not invisible, disenable, resize or put on back in progressDialog But now on Android O, Google allow build a nw kind permission from overlay widget, my solution was a widget call OverlayShowingService: For use need add permissions at AndroidManifest: ```xml ``` Using the library you could use two ways: ### SplashLoadingService Add Broadcast Service: ```xml ``` Invoke like a normal service: ```java svc = new Intent(activity, SplashLoadingService.class); // show layout getActivity().startService(); ussdApi.callUSSDOverlayInvoke(phoneNumber, simSlot, map, new USSDController.CallbackInvoke() { ... // dismiss layout getActivity().stopService(svc); ... } ``` ```kotlin svc = Intent(activity, OverlayShowingService::class.java) // show layout activity.startService(svc) ussdApi.callUSSDOverlayInvoke(phoneNumber, map, object : USSDController.CallbackInvoke { ... // dismiss layout activity.stopService(svc) ... } ```

Jitpack

### EXTRA: Use Voip line In this section leave the lines to call to Telcom (ussd number) for connected it: ```java ussdPhoneNumber = ussdPhoneNumber.replace("#", uri); Uri uriPhone = Uri.parse("tel:" + ussdPhoneNumber); context.startActivity(new Intent(Intent.ACTION_CALL, uriPhone)); ``` ```kotlin ussdPhoneNumber = ussdPhoneNumber.replace("#", uri) val uriPhone = Uri.parse("tel:$ussdPhoneNumber") context.startActivity(Intent(Intent.ACTION_CALL, uri)) ``` Once initialized the call will begin to receive and send the **famous USSD windows** ## Cordova Plugin * **cordova-plugin-VoIpUSSD** - [Ramy Mokako](https://github.com/rmxakalogistik/cordova-plugin-VoIpUSSD#cordova-plugin-voipussd) ## Contributors ✨ [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-) Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Romell D.Z. 福θΏͺ

πŸ’»

Abdullahi Yusuf

πŸ’»

Mohamed Hamdy Hasan

πŸ’»

Mohamed Daahir

πŸ’»

Ramy Mokako

πŸ”Œ
### License MIT. See the LICENSE file for the copyright notice. 2017, January