Intent拨打电话
2020-09-07 本文已影响0人
美晨菌
public static void call(Context context, String number) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
Intent intent = new Intent(Intent.ACTION_DIAL);
Uri data = Uri.parse("tel:" + number);
intent.setData(data);
context.startActivity(intent);
} else {
Intent intent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + number);
intent.setData(data);
context.startActivity(intent);
}
}