Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent.ACTION_CALL, Uri

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);
like image 940
Reazur Rahman Avatar asked Apr 05 '13 19:04

Reazur Rahman


4 Answers

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);
like image 53
Harry Avatar answered Nov 04 '22 17:11

Harry


Try this :

String toCall = "tel:" + number.getText().toString();

startActivity(new Intent(Intent.ACTION_DIAL,

Uri.parse(toCall)));
like image 39
Delgado Avatar answered Sep 19 '22 01:09

Delgado


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>   
like image 24
Nirav Ranpara Avatar answered Nov 04 '22 17:11

Nirav Ranpara


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>
like image 4
Pragadees Avatar answered Nov 04 '22 17:11

Pragadees