Sending ACTION_CALL Intent in Android containing h

2020-03-15 04:30发布

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

String uri = "tel:" + "*101#";

//String uri = "tel:" + "*101\u0023";

Intent intent;
intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));

4条回答
来,给爷笑一个
2楼-- · 2020-03-15 04:47

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);
查看更多
混吃等死
3楼-- · 2020-03-15 05:04

Found a solution: String encodedHash = Uri.encode("#"); this did the trick...

查看更多
4楼-- · 2020-03-15 05:05

This would be easier;

String no = textview.getText().toString();
if(no.contains("#")){
no = no.replace("#","%23");
}
startActivity(new Intent(Intent.ACTION_CALL)
.setData(Uri.parse("tel:" no)));
查看更多
混吃等死
5楼-- · 2020-03-15 05:06

I found a solution for this issue by replacing # in %23

String uri = "tel:" + "*133%23";

Intent intent;
intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));
查看更多
登录 后发表回答