How can I call Android JavaScript functions in WebView?

Let’s learn how can I call Android JavaScript functions in WebView. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

Android Calling JavaScript functions in WebView

I am trying to call some javascript functions sitting in an html page running inside an android webview. Pretty simple what the code tries to do below - from the android app, call a javascript function with a test message, which inturn calls a java function back in the android app that displays test message via toast. The javascript function looks like: function testEcho(message){ window.JSInterface.doEchoTest(message); } From the WebView, I have tried calling the javascript the following ways...

Answer:

I figured out what the issue was : missing quotes in the testEcho() parameter. This is how I got the...

Read more

user163757 at Stack Overflow Mark as irrelevant Undo

Other solutions

When I call a Java applet function by reference from JavaScript code, it doesn't work correctly.   Is it possible to call Java functions by reference from JavaScript? My guess: I think because Java takes memory on JVM, it is not possible.

// Java Code:     public class  A extends Applet{             public void foo(int[] a)         {             a[0]=3;         }     }         //Javascript Code:     var arg = new Array(1);     arg[0]=2;     Applet.foo(arg); But `arg[0]` remains `2`

Answer:

You are right, JavaScript arrays are copied and converted before they are passed to Java Code. From...

Read more

David Tanzer at Quora Mark as irrelevant Undo

Android: Why did they not separate out the Phone from the OS functions, not even allowing a call when it freezes?

When Android gets all caught up in itself [frozen by App's, or whatever], it ALSO means that you can't even make a call? How is that useful to a User?

Answer:

Well, the "phone" is just another application on the system that needs to run like everything...

Read more

Cliff Gilley at Quora Mark as irrelevant Undo

Is there a way to pass a message from an Android browser to an app?

I have a situation where I'd like for some data to be passed from a mobile web site to a native Android app. A complication is that, in the normal case, the native Android app might not be installed when the mobile web site is loaded. Here's an example...

Answer:

yes you can - you use data intent filters to catch certain protocols or URLs.have a look at http://developer...

Read more

Warren Miller at Quora Mark as irrelevant Undo

I want to call a function written in .cs code file in a .js (javascript). How to do this?   (There a way to call this cs function through Ajax call but dont have much idea about the same.)

For example there is a class  Sample.cs public class Test {  publiv void TestFunction()  {   // set of code  } } the TestFunction is to be called in the javascript function <script type="C#/javascript"> function TestCall() {  Test.TestFunction...

Answer:

It really depends that which technology stack are you in. I have asp.net background so I will answer...

Read more

Muhammad Haseeb Asif at Quora Mark as irrelevant Undo

What is the best way to create web app in android?

Whats the best way to create a web app in Android? I want to use all the native functions of android. I also want to implement the sliding menu API in action bar. Link: SlidingMenu. One way is using android webView and the other way is PhoneGap. Which...

Answer:

I think using cordova (phonegap) is the best approach since there are plugins available for most of...

Read more

Prabhu Swaminathan at Quora Mark as irrelevant Undo

As a web app owner, how can you detect when someone has re-published your app via UIWebView on iOS or a WebView in Android?

I have a very popular web app that I've discovered a number of people are re-publishing as Android and iOS apps without my permission.  Id like to present users with a link to our official apps.  Is there a way to use Javascript to probe the environment...

Answer:

Do you have your own iOS and Android apps?  If so, you can add a custom header to the page requests...

Read more

Pat Roberts at Quora Mark as irrelevant Undo

How can I mix javascript and php? With one button I want it to call a php function as well as a javascript function?

I am really struggling with this. If I use a submit button and then say: <?php if isset($_POST['buttonName']){ ?> call some javascript function. <?php } ?> The above code does not work properly. if do an onclick for the submit button...

Answer:

I would like you to go through Browser — Server Communication good discussion on this. What...

Read more

Ashish Kasama at Quora Mark as irrelevant Undo

Which files should I use to use Chromium as a webview for Android?

There's this android_webview directory in the source code of Chromium:http://src.chromium.org/viewvc/c... For speed, I want to use it instead of the default webview in Android. I built Chromium for Android (http://code.google.com/p/chromiu... AndroidBuildInstructions...

Answer:

It isn't as simple as copying a few .so files into your application resource directory. You have built...

Read more

Sahaj Sawhney at Quora Mark as irrelevant Undo

In JavaScript, since global variables are available to functions, is there ever any reason to pass them to functions through arguments?

In JavaScript, since global variables are available to functions, is there ever any reason to pass them to functions through arguments?

Answer:

Namespace pollution. Also, you often will want to pass different variables/values to the same function...

Read more

judytaos at Ask.Metafilter.Com Mark as irrelevant Undo

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.