Home > OS >  Why ACTION_CALL not working on Android 11
Why ACTION_CALL not working on Android 11

Time:12-10

Why does this sentence ( to place a call enter a valid number ) appear when I run this code?

                Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:"   "#1234#"));
                startActivity(intent);

But if you change the number from "#1234#" to "123456789" it works without problems Why is the (#) symbol not accepted?

Knowing that I added

       <uses-permission android:name="android.permission.CALL_PHONE" />

in AndroidManifest.xml

Note: It still works in versions less than Android 11 and accepts the (#) symbol without problems.

CodePudding user response:

Have you tried replacing "#" with "%"?

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:"   Uri.encode("#1234#")));
startActivity(intent);

This should solve your problem.

  • Related