From the course: Android Development: Understanding Intents

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Start a phone call

Start a phone call - Android Tutorial

From the course: Android Development: Understanding Intents

Start my 1-month free trial

Start a phone call

- Now let's see how to initiate a phone call using an implicit intent. So in AppsActivity.java I'm going to fill out the code for the btnStartPhoneCall button click case and I already have a string variable that contains the phone number that I want to dial and you can imagine this data could come from anywhere and you can see that I'm using a US 1-800 number, you can use whatever number works in your locale. I'm not actually going to be making the phone call because, you know, I'm in the emulator, but you can imagine if you're testing this on a real device it would actually work. So similar to the SMS message example that we saw earlier in the course, I need to create a URI that holds this phone number using the tel protocol, so I'll create that using the Uri class, and I'll call it numUri, and I'll call the parse function and I'm going to parse the tel protocol plus my phoneNumber variable. Okay, so that's going to give me a URI for the phone, so then I need to create the intent…

Contents