Code USSD Android Studio

walidoulwen

عضو نشيط
إنضم
24 جوان 2013
المشاركات
261
مستوى التفاعل
93
Bonjour

je besoin de code java d'un Button lorsque en clique doit exécuté un code USSD et affiche la résultat

merci de m’aide concernant le code java
 

Koossay

عضو جديد
إنضم
18 فيفري 2016
المشاركات
18
مستوى التفاعل
10
كود:
private void dialNumber(final String phoneNumber) {
    //permission is automatically granted on sdk<23 upon installation
    if (Build.VERSION.SDK_INT >= 23) {
        //Check if you have permissions to execute a call (number or USSD)
        if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            Log.v("TAG","Permission is granted");
            startActivity(new Intent(ACTION_CALL, Uri.fromParts("tel", phoneNumber, null)));

        } else {
            //Request permissions if we don't have them
            Log.v("TAG","Permission is revoked");
            ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.CALL_PHONE}, 1);
            startActivity(new Intent(ACTION_CALL, Uri.fromParts("tel", phoneNumber, null)));
        }
    }
    else {
        Log.v("TAG","Permission is granted");
        startActivity(new Intent(ACTION_CALL, Uri.fromParts("tel", phoneNumber, null)));
    }

}
تزيد هاذس في manifest
<uses-permission android:name="android.permission.CALL_PHONE" />
و تنادي للméthode
dialNumber("##323232#");
 
أعلى