Make USSD call in android

后端 未结 7 1149
南旧
南旧 2020-12-03 07:58

To check the balance first i have to make a call *xxx# and then i get a response with the multiple options to choose from and after i input the particular n

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 08:48

    Use this code, it works

    Intent callIntent = new Intent(Intent.ACTION_CALL);
    String ussdCode = "*" + 2 + Uri.encode("#");
    callIntent.setData(Uri.parse("tel:" +ussdCode));
    
    if (ActivityCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
                    return;
                }
    startActivity(callIntent);
    

    Add this line in Manifest file too

    
    

提交回复
热议问题