Bugfix for Android 14 for auto dialing mmi codes

This commit is contained in:
Jens 2023-12-18 22:55:18 +01:00
parent 38644cee28
commit c34dfa4af4

View File

@ -2287,7 +2287,18 @@ public class Actions
public static void startPhoneCall(Context context, String phoneNumber) public static void startPhoneCall(Context context, String phoneNumber)
{ {
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(phoneNumber))); Intent intent;
/*
Bug in Android 14 makes it necessary to add double quotes around MMI code.
More precisely it's required for codes containing the # character.
*/
if(Build.VERSION.SDK_INT >= 34)
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode("\"" + phoneNumber + "\"")));
else
intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(phoneNumber)));
// intent.setClassName("com.android.phone","com.android.phone.OutgoingCallBroadcaster"); // intent.setClassName("com.android.phone","com.android.phone.OutgoingCallBroadcaster");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_FROM_BACKGROUND); intent.addFlags(Intent.FLAG_FROM_BACKGROUND);