I have a question that I want to dial a phone call when I click on a text view which also contain a phone number. But when I click on a Text view it returns an error as:
Add permission to call in AndroidManifest.xml file.
In your textview of your layout.xml file
In your activity class. Run-time permission check added.
if (Build.VERSION.SDK_INT > 22) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MoreProgramDetailActivity.this, new String[]{Manifest.permission.CALL_PHONE}, 101);
return;
}
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+" + phoneTV.getText().toString().trim()));
startActivity(callIntent);
} else {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+" + phoneTV.getText().toString().trim()));
startActivity(callIntent);
}