How to make a phone call in android when user Click on textView then automatically dail a number in textView ?
TextView tv=(TextView) findViewById(R.id.tv_cont
Add permission to call in AndroidManifest.xml file.
First make your TextView clickable by adding below in your layout.xml
Then in your Activity Class, inside OnClickListener of that particular TextView add below code
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:+" + tv.getText().toString().trim()));
startActivity(callIntent);
} else {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:+" + tv.getText().toString().trim()));
startActivity(callIntent);
}