Android Intent.ACTION_CALL, Uri

android, android-intent

Solution

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>   

Problem

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); ```

Original source

Related problems