Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Activity found to handle Intent { act=android.intent.action.CALL dat=+123456789 pkg=com.android.phone }

Tags:

android

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);
like image 594
user1382802 Avatar asked Jan 17 '16 11:01

user1382802


1 Answers

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.

like image 88
Mohammad Rahchamani Avatar answered Oct 25 '22 11:10

Mohammad Rahchamani