android呼叫撥打電話(包括執行時許可權)
阿新 • • 發佈:2019-02-13
/**
* 撥打電話(跳轉到撥號介面,使用者手動點選撥打)
*
* @param phoneNum 電話號碼
*/
public void diallPhone(String phoneNum) {
Intent intent = new Intent(Intent.ACTION_DIAL);
Uri data = Uri.parse("tel:" + phoneNum);
intent.setData(data);
startActivity(intent);
}
/**
* 撥打電話(直接撥打電話)
*
* @param phoneNum 電話號碼
*/
public void callPhone(String phoneNum) {
Intent intent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + phoneNum);
intent.setData(data);
startActivity(intent);
}
<uses-permission android:name="android.permission.CALL_PHONE" />