Hello I wanting to make a simple button click which allows the user to call a specific number when pressed. Before API 23 I code simply add the permission to the manifest and away we go but now I have to add this self check system. The problem I having with the line
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
As (this) has a red underline telling me it's the wrong 1st argument type. Being that this is my first time with this self check problem, how would I go about fixing the error?
call = (Button) findViewById(R.id.btnCall);
call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123"));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
}
});
Thank you