我想調用系統的電話功能,寫了以下代碼:
Intent intent = new Intent(Intent.Action_CALL ,Uri.parse("110"));
startActivity(intent);
但是發生ActivtynotfoundException 錯誤
試了幾個方法發現不行,遂百度。發現外國網友的一個錯誤跟我的很像,他的是調用系統的信息發生這個錯誤。有人說這樣改
Intent intent = new Intent(Intent.Action_CALL ,Uri.parse(String.format("tel:%d","110"));
startActivity(intent);
改完后錯誤消失,這是那個人的解釋
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
新聞熱點
疑難解答