0

I'm using cordova/phonegap to make a Android app and trying to call JavaScript funtion from android/native

My main acitvity:-

public class MainActivity extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);


        // Set by <content src="index.html" /> in config.xml
        loadUrl(Url);

        // TODO call javascripte from here 

    }
}

My index.html page

<!DOCTYPE HTML>
    <html>
      <head>
        <title>PhoneGap</title>

        <script type="text/javascript" charset="utf-8">

        function myFun(){
          alert("call from the ANDROID");
        }
        </script>

    </head>
    <body >
    </body>
    </html>

I want call JavaScript function from phonegap.

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
user5716434
  • 1
  • 1
  • 3
  • check this http://stackoverflow.com/questions/11716167/how-to-call-javascript-function-from-android-using-phonegap-plugin – Mavlarn Jan 06 '16 at 05:06
  • No that is not working :-( . – user5716434 Jan 06 '16 at 05:19
  • Use PluginResult. Check http://stackoverflow.com/questions/30453415/call-javascript-from-cordovaactivity or http://d.hatena.ne.jp/yohpapa/20130819/1376947942, for example. – CoolMind Jun 23 '16 at 12:42

1 Answers1

4

try this code

webView.loadUrl("javascript:myFun()");
prabhakaran
  • 147
  • 2
  • 13