I am running this code in the onCreate
method to try to get permission, but for some reason it is giving me the error:
Incompatible types required int found boolean for this part: if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.READ_SMS) + ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.SEND_SMS))
@Override
protected void onCreate(Bundle savedInstanceState) {
if (ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.READ_SMS) +
ContextCompat.checkSelfPermission(MainActivity.this, android.Manifest.permission.SEND_SMS))
!= PackageManager.PERMISSION_GRANTED) {
if (AppCompatActivity.shouldShowRequestPermissionRationale(this,"Manifest.permission.READ_SMS") ||
AppCompatActivity.shouldShowRequestPermissionRationale(this,"Manifest.permission.READ_SMS")) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(this,
new String[]{"Manifest.permission.READ_SMS, Manifest.permission.SEND_SMS"},
REQUEST_CODE);
// REQUEST_CODE is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
else {
// Permission has already been granted
}