简体   繁体   中英

Android Intent.ACTION_CALL: phone number with # char

I want to make a phone call to *142#

However, it dials *142 only, the # is ignored.

Here is my code

Button button = (Button) findViewById(R.id.balance);

myButton.setOnClickListener(new OnClickListener() 
{
    @Override
    public void onClick(View view)
    {
        Intent intent = new Intent(Intent.ACTION_CALL);
        intent.setData(Uri.parse("tel:" + telephoneNumber));
        startActivity(intent);
    }
}

I set the telephoneNumber as *142# , but still it dials *142 . What can I do to make sure it dials *142# ? with the # at the end ?

URL encode the number with URLEncoder .

# has special meaning in URI syntax and needs to be encoded as %23 to be treated literally as # .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM