Question

I want to launch an contact-activity when a input-field (text) in a webview is pressed. Not sure how I can do this. Have tried to search the web but the only results I get is how to launch a filebrowser when a "input-file-field" is pressed.. And it seems like Android have an option that is exactly for that purpose, but not when another input-type is pressed?

What I actually want to do is;

when the input field is pressed, I want to give the user an option to launch the contact manager (or something similar) to choose one or more contacts from its contactlist.

Then fill the input-field with the contacts emails, separated with commas.

Is it possible to do this? Any idea what I should search the web for?

Was it helpful?

Solution

Solved! Added a new class:

import android.content.Context;
import android.content.Intent;

public class JSFromPage {

    Context mContext;

    JSFromPage(Context c) {
        mContext = c;
    }

    public void openContact() {

        Intent intent = (Intent) new Intent( mContext, ListContacts.class );
        mContext.startActivity( intent );

    }

}

And uses this is my WebView class:

mWebView.addJavascriptInterface(new JSFromPage(this), "Android");

And this is my html on the input:

onclick="Android.openContact();" 

Then i created the class "ListContacts.class" with a new activity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top