I am trying to use the Intent.Action class. I know how to use the ACTION_VIEW to display a URL but I wanted to use the Intent.ACTION_DIAL
to call number when the application is launched. The documentation says you need to parse a URI into a string and then add it to the Intent I tried this:
Uri call = Uri.parse("7777777777");
Intent surf = new Intent(Intent.ACTION_DIAL, call);
startActivity(surf);
This doesn't work I get an error message saying:
Unfortunately, Project has stopped. I tried to debug the code and it seems to point me to the intent line not sure what I doing wrong if I just do this it works and brings up the dialer.
//Uri call = Uri.parse("7777777777");
Intent surf = new Intent(Intent.ACTION_DIAL);
startActivity(surf);
To just open the dialer app (the user has to press the call button inside the dialer app; no additional permissions needed) use:
String number = "7777777777";
Uri call = Uri.parse("tel:" + number);
Intent surf = new Intent(Intent.ACTION_DIAL, call);
startActivity(surf);
To open the dialer app and do the call automatically (needs android.permission.CALL_PHONE) use:
String number = "7777777777";
Uri call = Uri.parse("tel:" + number);
Intent surf = new Intent(Intent.ACTION_CALL, call);
startActivity(surf);
Try this :
String toCall = "tel:" + number.getText().toString();
startActivity(new Intent(Intent.ACTION_DIAL,
Uri.parse(toCall)));
tel
String number = "23454568678";
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" +number));
startActivity(intent);
Use Permission
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
Try this also
Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phno);
startActivity(intent);
Android Manifest
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With