0

My dialer is just showing "*16001":

 private Button checksim;
    private String number = "*16001#";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bangladeshsimverification);

        checksim = findViewById(R.id.b_b_check);
        checksim.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent opendialer = new Intent(Intent.ACTION_DIAL);
                opendialer.setData(Uri.parse("tel:" + number));
                if (opendialer.resolveActivity(getPackageManager()) != null) {
                    startActivity(opendialer);
                }
            }
        });

    }

I want to add '#' at the end of this string, but it is not working. How can I achieve this?

ouflak
  • 2,458
  • 10
  • 44
  • 49
  • https://stackoverflow.com/questions/7280209/sending-action-call-intent-in-android-containing-hash-sign – ouflak Jan 13 '22 at 18:32
  • 3
    Does this answer your question? [Sending ACTION\_CALL Intent in Android containing hash # sign](https://stackoverflow.com/questions/7280209/sending-action-call-intent-in-android-containing-hash-sign) – ouflak Jan 13 '22 at 18:32

1 Answers1

-1

For your case, Uri.parse method cannot handle special character like '#'. A simple way around is to encode the string with proper formatting before using Uri.parse.

For example, try using:

URLEncoder.encode(value, StandardCharsets.UTF_8.toString());