What I had to achieve here was to fire up Phone dialer when I click on the link which contains
tel:. This is something similar to
mailto: which will trigger your email client to open up and you can write email to the address specified.
Using the Code
Well just adding the link doesn't work in the Webview. So we need to create an Intent to start the Phone dialer. The solution below has been implemented in Android for now and not on iOS. Will put an addendum once done.
So to do this, we use Dependency Injection like this:
- Create an Interface in your PCL:
public interface IAppIntents
void HandleWebviewUri(string uri);
- Now create a class in your Android project to implement the above
public class AppIntents_Droid : IAppIntents
public void HandleWebviewUri(string uri)
var appUri = Android.Net.Uri.Parse(uri);
var appIntent = new Intent(Intent.ActionView, appUri);
- Whenever user clicks on a link in Webview, a
Navigating event is fired which we need to capture and call the above method:
void WvMain_Navigating(object sender, WebNavigatingEventArgs e)
Pretty simple right!
Points of Interest
Xamarin is a wonderful framework to work with if you have a craving to develop Web apps. With Webview, you can extend your existing Web developer skills to develop great mobile apps. Do let me know if you implement it in your project and if you find this article helpful.
I am a senior software developer. I work for a web development company as team lead. Most of the solutions developed by myself are for web using DotNet Framework but do have keen interest in developing for mobile app as well. At work I am responsible to provide solutions to clients and work with dynamic teams developing for web and mobile. I have been closely working with teams and mentoring them developing in technologies like ASP.Net and PHP for Web and Objective C, Android SDK and cross platform Mobile app.
I like to try my hands-on various other web and mobile development technologies. My current interests apart from ASP.Net (WebForms, MVC and DotNet Core) is for NodeJS, Angular, React and Typescript for developing Web and Mobile Apps. I have been constantly exploring new technologies and implementations for CI/CD, Source Control & Versioning and Automation. Also, looking forward to work on Bots, Machine learning, IoT, VR & AR.
I use tools to do my work and suit my workflows. I was made aware of blogging during my training at Aptech and has been constantly working on having blogs for myself and my work. Including this blog there are few more links of my online presence mentioned below.