I need to call a given phonenumber from my application.
so i have to verify the permission for call.
but the dialog is showing in my application, straightly it is going the deny function. what is the issue i have done here. please review my code and give me a solution for this.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, 105);
} else {
startActivity(callIntent);
}
} else {
startActivity(callIntent);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case 105:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
callJobseeker();
} else {
Toast.makeText(getApplicationContext(), "You cannot make a call.Because call permission is denied", Toast.LENGTH_SHORT).show();
}
break;
}
}
in the manifest file am given the permission like :
<uses-permission android:name="android.permission.CALL_PHONE" />
<permission android:name="com.example.permission.CALL_PHONE"
/>