Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read USSD Message response in android

i want to store my balance in sqlite database i am successfully dial the USSD

String balance_check="*444";
String encodedHash = Uri.encode("#");
  String ussd = balance_check + encodedHash;
 startActivityForResult(new Intent("android.intent.action.CALL",Uri.parse("tel:" + ussd)), 1);  

Here is onActivityResult function

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1) {
    if (resultCode == RESULT_OK) {
            String dd = data.toString();
            Log.d("myussdmessage", data.toString());}}

but I cannot get the string exactly how to do it.I want to store the balance form the dialogue to my database.Can any one suggest me how to do it.

like image 711
Nouman Shah Avatar asked Nov 26 '25 22:11

Nouman Shah


1 Answers

You need to build an AccessibilityService in order to do that you need to read the documentation of AccessibilityService in below link https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html

and also this question helped me

Prevent USSD dialog and read USSD response?

like image 167
Martin Avatar answered Nov 28 '25 12:11

Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!