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?
This question is related to
android
android-intent
phone-number
<TextView
android:id="@+id/phoneNumber"
android:autoLink="phone"
android:linksClickable="true"
android:text="+91 22 2222 2222"
/>
This is how you can open EditText label assigned number on dialer directly.
As @ashishduh mentioned above, using android:autoLink="phone
is also a good solution. But this option comes with one drawback, it doesn't work with all phone number lengths. For instance, a phone number of 11 numbers won't work with this option. The solution is to prefix your phone numbers with the country code.
Example:
08034448845
won't work
but +2348034448845
will
Okay, it is going to be extremely late answer to this question. But here is just one sample if you want to do it in Kotlin.
val intent = Intent(Intent.ACTION_DIAL)
intent.data = Uri.parse("tel:<number>")
startActivity(intent)
Thought it might help someone.
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.
Source: Stackoverflow.com