@Override
public
void
onClick(View v) {
if
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int
permissionResult = checkSelfPermission(Manifest.permission.CALL_PHONE);
if
(permissionResult == PackageManager.PERMISSION_DENIED) {
if
(shouldShowRequestPermissionRationale(Manifest.permission.CALL_PHONE)) {
AlertDialog.Builder dialog =
new
AlertDialog.Builder(AdminMain.
this
);
dialog.setTitle(
"권한이 필요합니다."
)
.setMessage(
"이 기능을 사용하기 위해서는 단말기의 \"전화걸기\"권한이 필요합니다 계속하시겠습니까?"
)
.setPositiveButton(
"네"
,
new
DialogInterface.OnClickListener() {
@Override
public
void
onClick(DialogInterface dialog,
int
which) {
if
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(
new
String[]{Manifest.permission.CALL_PHONE},
1000
);
}
}
})
.setNegativeButton(
"아니요"
,
new
DialogInterface.OnClickListener() {
@Override
public
void
onClick(DialogInterface dialog,
int
which) {
Toast.makeText(AdminMain.
this
,
"기능을 취소했습니다"
, Toast.LENGTH_SHORT).show();
}
})
.create()
.show();
}
else
{
requestPermissions(
new
String[]{Manifest.permission.CALL_PHONE},
1000
);
}
}
else
{
Intent intent =
new
Intent(Intent.ACTION_CALL, Uri.parse(
"tel:"
+ tel));
startActivity(intent);
}
}
else
{
Intent intent =
new
Intent(Intent.ACTION_CALL, Uri.parse(
"tel:"
+ tel));
startActivity(intent);
}
}
});
}