1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| private boolean hasPermission() { if (checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return false; } return true; }
private void intentToCall(String phoneNumber) { Intent intent = new Intent(Intent.ACTION_CALL); Uri data = Uri.parse("tel:" + phoneNumber); intent.setData(data); startActivity(intent); }
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == 0x11) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { CldLog.i("CMCC", "权限被允许"); String phone = mContactsInfo.getPhone(); intentToCall(phone); } else { CldLog.i("CMCC", "权限被拒绝"); } } }
|