0

i have page contains javascript function in web page...

function callFromAndroid(varName)
{
 alert("call from android activated by " + varName);
}

i want call javascript function callFromAndroid() from android...

Is this possible?

Please explain how it can be done or point me to a resource where I can find such information.

thanks

1 Answer 1

2

Given a WebView named wv, call:

wv.loadUrl("javascript:callFromAndroid("+whateverYourVarValueIsAsJavaScriptLiteral+")");

The string passed to loadUrl() needs to be a javascript: scheme URL, with the literal source code you wish to invoke after the colon. This follows the same pattern as with bookmarklets.

Sign up to request clarification or add additional context in comments.

4 Comments

i mean,i have javascript function in internet mydomain.com/index.php..and android is the client..i want pass value from android device and send to that page..
@ltvie: Write an Android app that uses a WebView to serve as your "client", then use the recipe I have in my answer.
sorry, i understand with your answer..i new android develop..but as known a webView located in android device?not in webserver?
@ltvie: "a webView located in android device?" -- yes. "not in webserver?" -- correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.