Hi Im trying to get a certain variable value from a local HTML page. The function simply returns the value of a simple variable called x ( x is set to 5 ) so I want to call this function in android. Here is my code so far:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setSaveFormData( false );
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl( "file:///android_asset/tester.html" );
getScript = (Button) findViewById( R.id.test );
getScript.setOnClickListener( new View.OnClickListener()
{
@Override
public void onClick(View v)
{
mWebView.loadUrl( "javascript:getX()" );
}
});
Toast.makeText( this, "Hello World", duration );
}
So the idea is that when the getScript button is called it calls the function on the HTML page but how would i get that value displayed? Like in the toast message below it?
Cheers