You are on page 1of 1

eText = (EditText) findViewById(R.id.

editText);
btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast msg = Toast.makeText(getBaseContext(),"Button pressed",
Toast.LENGTH_LONG);
String str = eText.getText().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+eText.getText()));

if (ActivityCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.CALL_PHONE) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);

Toast msg1 = Toast.makeText(getBaseContext(),str,


Toast.LENGTH_LONG);
msg.show();
}
});
}
}

You might also like