Naveen
Naveen

Reputation: 1060

Create Contact in Phone from WebView html - Android App

Is it possible to add a contact (only mobile number) to the phone from WebView HTML page?

Any pointers would be quite helpful.

Upvotes: 1

Views: 2525

Answers (2)

user370305
user370305

Reputation: 109237

I think its possible, (But never try this)..

  1. Load your webpage in android webview in that make a javascript which is fetch the mobile number from the HTML page.

  2. Make a Android function to add a mobile number in contact and call that function from java script.

Use Java Script interface for calling Android function from JAVA Script.

TO communicate between Java Script and Android function look at this example Android WebView Also Android WebView, Javascript and CSS

EDIT: Look at this tutorial for how to add contacts in android Contacts API 2.0 and above | Android Developer Tutorial and Android How-To: Create a new Contact.

Upvotes: 1

Sarwar Erfan
Sarwar Erfan

Reputation: 18068

Put this in html page where you want user to click to create phonebook entry:

<a href="wtai://wp/ap;5551234;My Name">Add 5551234  to phonebook</a>

When this page is loaded in WebView or browser and user clicks on the link, new phonebook entry screen will appear.

It will work on almost any phone.

I have put the html in a test web page. Visit from your mobile to test.

To know more about the protocol, read this

Upvotes: 1

Related Questions