Issue
By using an app I want to run a USSD code, but the problem is it doesn't recognize the "#" symbol. If I want to run "*100#" it recognize the input only as "*100". How to add the "#". and what is the reason to not recognize that?
Here is my code ...
checkBalance.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse("tel:"+"*100#"));
if (ActivityCompat.checkSelfPermission(mobitelPage.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(i);
}
});
Solution
Try this code.Use Uri.encode("#")
:
String encodedHash = Uri.encode("#");
i.setData(Uri.parse("tel:"+"*100"+encodedHash));
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(i);
Answered By - Ahmad Aghazadeh
Answer Checked By - Mary Flores (JavaFixing Volunteer)