Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
You must have seen several apps which opens a dialer with a specific number or even directly make a call to them. This functionality is quite easy to implement and very useful.
Let us look at the different ways to do the required task.
1) If you have a TextView which is displaying a phone number and you want to call on that number on a tap then this can be achieved by adding the autoLink attribute to the TextView.
But this one comes with a drawback that it doesn’t work for all kind of phone numbers. For example, a phone number of 11 numbers won’t work with this option. The solution is to prefix your phone numbers with the country code (09876543210 won’t work but +1569876543210 will work).
This doesn’t even need permission. Just add the attribute and you are good to go.
2) You can do the same programmatically also. The Intent.ACTION_DIAL will take you to the dialer screen all you need to do is add the phone number in the data.
The ‘tel:’ prefix is required, otherwise the following exception will be thrown: java.lang.IllegalStateException: Could not execute method of the activity.
3) If you want to directly make a call then this needs a CALL_PHONE permission. Add the permission in your AndroidManifest and change the ACTION_DIAL to ACTION_CALL in the above method.
Thank you very much. This is Vedesh Kumar signing off.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
It was a successful collaboration. The Mobikul team provided the client everything they needed in a timely and high-quality manner. They were very professional, reliable, and accessible during the entire process. The client also saw no room for any improvements in the vendor's performance.
Vincenzo Carrano
Administrator, Segshop
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.