Dialing with Intent.ACTION_CALL stopps at # in phone number
I try to dial the phone number 03012345,1234,#31#,98765 (callthrough with a FRITZ!Box)
"03012345" is the phone number of the FRITZ!Box, "," are dial pauses, "#31#" is a prefix to show my own phone number to the callee and "98765" is the phonenumber of the开发者_运维百科 callee.
String phonenumber = "03012345,1234,#31#,98765";
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phonenumber)));
On my smartphone, everything works fine, but some user reported to me, that their smartphones stopp dialing after the first #. But when they dial from contacts, it works.
Maybe, Uri.parse
splits the phone number? Or is there another way to dial such a phone number?
Here is the solution:
String phonenumber = "03012345,1234,#31#,98765"; // , = pauses
encodedPhonenumber = URLEncoder.encode(phonenumber, "UTF-8");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + encodedPhonenumber)));
You simply have to encode the phone number.
Really late on the answer, but another way that this can be done is with Uri.Builder
. Using encodedPath()
assumes that the string you're passing is already encoded, so it will be added to the Uri
as is:
final String phonenumber = "03012345,1234,#31#,98765";
final Uri uri = new Uri.Builder().scheme("tel").encodedPath(phonenumber).build();
startActivity(new Intent(Intent.ACTION_CALL, uri));
精彩评论