• Stars
    star
    163
  • Rank 223,896 (Top 5 %)
  • Language
    Java
  • License
    GNU General Publi...
  • Created almost 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

:octocat: 📞 IMEI (USSD) Library in Android Devices by @romellfudi

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

Target Development High Quality:

Jitpack

Interactive with ussd windows, remember the USSD interfaces depends on the System Operative and the manufacturer of Android devices.

Community Chat

Gitter

Downloads Dashboard

Data Studio

USSD LIBRARY

Implementations

Add the following dependency in your app's build.gradle configuration file:

Repository implementation Status
jcenter() 'com.romellfudi.ussdlibrary:ussd-library:1.1.i' DEPRECATED
jcenter() 'com.romellfudi.ussdlibrary:kotlin-ussd-library:1.1.k' DEPRECATED
maven { url https://jitpack.io } 'com.github.romellfudi.VoIpUSSD:ussd-library:1.4.a' READY
maven { url https://jitpack.io } 'com.github.romellfudi.VoIpUSSD:kotlin-ussd-library:1.4.a' READY
  • Writing a config xml file from here to res/xml folder (if necessary), this config file allow to link between Application and System Oerative:
<?xml version="1.0" encoding="utf-8"?>
<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:

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

Add service:

java
    <service
        android:name="com.romellfudi.ussdlibrary.USSDService"
        android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
        <intent-filter>
            <action android:name="android.accessibilityservice.AccessibilityService" />
        </intent-filter>
        <meta-data
            android:name="android.accessibilityservice"
            android:resource="@xml/ussd_service" />
    </service>
kotlin
    <service
        android:name="com.romellfudi.ussdlibrary.USSDServiceKT"
        android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
        <intent-filter>
            <action android:name="android.accessibilityservice.AccessibilityService" />
        </intent-filter>
        <meta-data
            android:name="android.accessibilityservice"
            android:resource="@xml/ussd_service" />
    </service>

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",...
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")));
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

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
    }
});
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:

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
    }
    ...
});
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

ussdApi.callUSSDInvoke(phoneNumber, simSlot, map, new USSDController.CallbackInvoke() {
    ...
}
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:

 # check if accessibility permissions is enabled or not
    ussdApi.verifyAccesibilityAccess(Activity)
 # check if overlay permissions is enabled or not
    ussdApi.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:

<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />

Using the library you could use two ways:

SplashLoadingService

Add Broadcast Service:

<service android:name="com.romellfudi.ussdlibrary.SplashLoadingService"
         android:exported="false" />

Invoke like a normal service:

svc = new Intent(activity, SplashLoadingService.class);
// show layout
getActivity().startService();
ussdApi.callUSSDOverlayInvoke(phoneNumber, simSlot, map, new USSDController.CallbackInvoke() {
        ...
        // dismiss layout
        getActivity().stopService(svc);
        ...
}
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:

ussdPhoneNumber = ussdPhoneNumber.replace("#", uri);
Uri uriPhone = Uri.parse("tel:" + ussdPhoneNumber);
context.startActivity(new Intent(Intent.ACTION_CALL, uriPhone));
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

Contributors

All Contributors

Thanks goes to these wonderful people (emoji key):


Romell D.Z. 福迪

💻

Abdullahi Yusuf

💻

Mohamed Hamdy Hasan

💻

Mohamed Daahir

💻

Ramy Mokako

🔌

Md Mafizur Rahman

💻

License

GNU GPLv3 Image

GameDealz is a Free Software: You can use, study share and improve it at your will. Specifically you can redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

More Repositories

1

FudiNFC

:octocat: 💳 NFC Reader And Writer using Android devices by @romellfudi
Kotlin
95
star
2

FudiPermission

:octocat: ⚔️quickly way to use Android permissions by @romellfudi
Java
18
star
3

FudiSharePreference

:octocat: ⚙️Android library from store Any kind of Data by @romellfudi
Kotlin
7
star
4

FudiAnnotation

⚙️Android Annotation Library for Widgets Design
Java
7
star
5

DatascienceNotebooks

📚 Builder project structure for data science workspace. 🤖
Python
3
star
6

MockitoSample

🍸How Android Test Unit with Mockito by @romellfudi
Java
2
star
7

AndroidSonarqubeSample

🚀Details to connected Android Project with SonarQube
HTML
2
star
8

CircleCiSample

:octocat: 🚀Testing Android project with CircleCi framework by @romellfudi
Java
2
star
9

CallbacksSample

:octocat: ⛳Sample project to use Callbacks in Java & Kotlin by @romellfudi
Java
2
star
10

MinCeTur

✈️ Data Visualization the satisfaction rate for Tourism in Peru 🚃🚐 🇵🇪
Jupyter Notebook
2
star
11

CircleCiSampleOnBitbucket

:octocat: 🚀Testing Android project with CircleCi framework by @romellfudi
Java
2
star
12

romellfudi

:octocat: Hello there! This repository is for my Github Profile.
2
star
13

assets

🗃️ miscellania & stuffs ♻️
2
star
14

AndroidLibProject

🏃Build template structure for Android MVP with coockiecutter by @romellfudi
HTML
2
star
15

LimaTweets_NLP_TFIDF

🇵🇪 DataScience technologies for Lima's tweets
Jupyter Notebook
1
star
16

ExploratoryDataAnalysis

⚽ EDA from Peru Road To World Cup 2018 🇵🇪 by @romellfudi
Jupyter Notebook
1
star
17

MachineLearing

🏆 Machine Learning Estimators
Jupyter Notebook
1
star
18

bills_tf_android

Making a nn to different Peruvian Bills
Jupyter Notebook
1
star
19

ImageProcessing

🌄Digital Image Processing - Different Techniques
Jupyter Notebook
1
star
20

dataset_currency

💵Model Peruvian Bills (MLR, Mask, Inceptionv2) RCNN💶
Jupyter Notebook
1
star
21

MockitoJfrogArtefactorySample

🚀Deploying AndroidLibrary into private repository
Java
1
star
22

markdown

:octocat: Post for jekyll theme @romellfudi
Python
1
star
23

CPM-SANNA

🏥Corporate Performance Management at SANNA 🏪 by @romellfudi
JavaScript
1
star
24

MathLearning

🎨 Amazing Javascript Projects
JavaScript
1
star