Sending ACTION_CALL Intent in Android containing hash # sign

后端 未结 4 1112
野性不改
野性不改 2021-01-12 07:23

I am having the problem that the hash sign is truncated. Does anybody know a solution? using unicode or %23 is not working in my case. Now the number that is dialed is *101<

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 08:02

    An all in one solution would be:

                String number = "*123#";
                number =  number.replace("*", Uri.encode("*")).replace("#",Uri.encode("#"));
                Intent mIntent = new Intent(Intent.ACTION_CALL);
                Uri data = Uri.parse("tel:" + number);
                mIntent.setData(data);
                startActivity(mIntent);
    

提交回复
热议问题