0

I have a button and EdiText. in the EdiText I enter a phone number. By clicking on the button I need to call on this phone. but does not cause CallActivity and call directly from the application. how to do it?

tel = (EditText) findViewById(R.id.editText);
...
public void clic(View view) {
     String number = tel.getText().toString();

    }

and

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>

1 Answers1

0

For direct calling from your app, which will place a call (But you have to add permission for it)

 Intent callIntent = new Intent(Intent.ACTION_CALL);
          callIntent.setData(Uri.parse("tel:"+Uri.encode(PhoneNum.trim())));
          startActivity(callIntent); 

For opening DIAL screen, (You don't have to add ANY permission for it)

 Intent callIntent = new Intent(Intent.ACTION_DIAL);
          callIntent.setData(Uri.parse("tel:"+Uri.encode(PhoneNum.trim())));
          callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          startActivity(callIntent); 
Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83