The following code works fine when I click a button in an activity but gets an "No Activity found to handle Intent" error when a button in an fragment is clicked.
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("+123456789"));
startActivity(callIntent);
I think you should say that the data you are adding is tel number like this :
callIntent.setData(Uri.parse("tel:+123456789"));
here is a complete solution:
first of all, add the following permission to your manifest.xml
<uses-permission android:name="android.permission.CALL_PHONE" />
then use following code for making call :
String phone = "+34666777888";
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", phone, null));
startActivity(intent);
update :
you don't need CALL_PHONE
permission for ACTION_DIAL
.
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