Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the dialer to open with phone number displayed?

I don't need to call the phone number, I just need the dialer to open with the phone number already displayed. What Intent should I use to achieve this?

like image 333
Nik Avatar asked Jul 28 '12 09:07

Nik


People also ask

How do I get my phone Dialer back?

If so, go to Settings>Apps>Disabled, select Dialer, and tap Enable. If there isn't a Disabled list, go to Settings>Apps>All​, and scroll all the way to the bottom to find the Disabled apps. In Samsung the app is called "Phone" that you want to restore/add back to your home screen.

How do I access my Dialer?

In your App Drawer (application list) by default, you should find the Voice Dialer included with nearly all Android versions. Tap Voice Dialer to open it. Note you can always add this “app” to your home screen for easy and quick access.


2 Answers

Two ways to achieve it.

1) Need to start the dialer via code, without user interaction.

You need Action_Dial,

use below code it will open Dialer with number specified

Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:0123456789")); startActivity(intent);  

The 'tel:' prefix is required, otherwhise the following exception will be thrown: java.lang.IllegalStateException: Could not execute method of the activity.

Action_Dial doesn't require any permission.

If you want to initiate the call directly without user's interaction , You can use action Intent.ACTION_CALL. In this case, you must add the following permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.CALL_PHONE" /> 

2) Need user to click on Phone_Number string and start the call.

android:autoLink="phone"  

You need to use TextView with below property.

android:autoLink="phone" android:linksClickable="true" a textView property

You don't need to use intent or to get permission via this way.

like image 149
AAnkit Avatar answered Sep 16 '22 14:09

AAnkit


Pretty late on the answer, but if you have a TextView that you're showing the phone number in, then you don't need to deal with intents at all, you can just use the XML attribute android:autoLink="phone" and the OS will automatically initiate an ACTION_DIAL Intent.

like image 33
ashishduh Avatar answered Sep 18 '22 14:09

ashishduh