I need to execute USSD codes from my app of type: #222*1# (hash222star1hash) I'm working on Android Studio
. I have tried with Intent.ACTION.CALL
:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:#222*1#"));
startActivity(intent);
To call a normal number (123456789) it works, but for the previous case it tells me that "the number entered is not valid .
What should I do?
Hello do the following to concatenate the value
"#"
->Uri.encode("#");
For example, for your case:
What you need is to simply encode the character
#
, and through an intent make the call:It is important to comment that you need permissions declared in your
AndroidManifest.xml
:but in the case of devices with an operating system greater than Android 6.0 , you need to declare them manually, here you can find how to do it:
Intent.ACTION_CALL fails on android 6+
and I suggest you validate that before calling you verify that you have the permissions, otherwise do not try to do the
intent
, since it will mark an error:It works for me this way: In addition to giving the necessary permissions...
Luck...