-3

I met a problem But I don't know where the problem is This is my code

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("tel:"+"phonenumber" ));
startActivity(intent);
Charuක
  • 12,953
  • 5
  • 50
  • 88

1 Answers1

0

Try this:

Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("tel:%s", phonenumber)));
startActivity(in);
Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
  • thanks for you help.But I want to know why this happened.I think my code is ok,but it really happened. – hellolsh Dec 16 '16 at 09:16
  • Are you sure you used the phone number variable or "phonenumber" as a string value. This is why I suggested the String.format as opposed to string concatenation. ACTION_VIEW should be fine, so the only possible point of failure is the URI – Quintin Balsdon Dec 16 '16 at 09:19