Failing to call java function in android with javascript
<p>So i am trying to make this simple Android application with only WebView pointed at my server from witch it gets the appropriate html. Everything is working except the Javascript interface. I googled alot for this, but can't find my mistake :( Here is the code for the interface:</p>

<pre><code>public class JavaScriptInterface extends Activity{
Context mContext;

JavaScriptInterface (Context c){
    mContext = c;
}

public void showToast(){
    Toast.makeText(mContext, "Hello World", Toast.LENGTH_SHORT).show();

}
public void pozovi(String s) {
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:"+s));
        startActivity(callIntent);
    } catch (ActivityNotFoundException e) {
        Log.e("Error", "Call failed", e);
    }
}

public void posaljiPoruku(String broj, String poruka){
    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
    sendIntent.putExtra("sms_body", poruka);
    sendIntent.putExtra("address", broj);
    sendIntent.setType("vnd.android-dir/mms-sms");
    startActivity(sendIntent);
}
</code></pre>

<p>}</p>

<p>and here is how i added the interface:</p>

<p><code>glavni.addJavascriptInterface(new JavaScriptInterface(this), "Android");</code></p>

<p>The javascript i use to call this is: </p>

<pre><code>function toast(){
        Android.showToast();
    }
</code></pre>

<p>I know its a long piece of code, but i really need some help since this is my first android app. When i click the button that calls the javascript, the emulator just shows me the home screen.</p>

<p>This is my LOGCAT output...</p>

<pre><code>06-01 16:25:33.924: W/dalvikvm(335): JNI WARNING: jarray 0x40683860 points to non-array object (Ljava/lang/String;)
06-01 16:25:33.924: I/dalvikvm(335): "WebViewCoreThread" prio=5 tid=9 NATIVE
06-01 16:25:33.924: I/dalvikvm(335):   | group="main" sCount=0 dsCount=0 obj=0x4051bef0 self=0x29a890
06-01 16:25:33.924: I/dalvikvm(335):   | sysTid=344 nice=0 sched=0/0 cgrp=default handle=2730440
06-01 16:25:33.934: I/dalvikvm(335):   | schedstat=( 5188857693 1923655665 523 )
06-01 16:25:33.934: I/dalvikvm(335):   at android.webkit.WebViewCore.nativeTouchUp(Native Method)
06-01 16:25:33.934: I/dalvikvm(335):   at android.webkit.WebViewCore.nativeTouchUp(Native Method)
06-01 16:25:33.964: I/dalvikvm(335):   at android.webkit.WebViewCore.access$3300(WebViewCore.java:53)
06-01 16:25:33.964: I/dalvikvm(335):   at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1158)
06-01 16:25:33.964: I/dalvikvm(335):   at android.os.Handler.dispatchMessage(Handler.java:99)
06-01 16:25:33.964: I/dalvikvm(335):   at android.os.Looper.loop(Looper.java:123)
06-01 16:25:33.976: I/dalvikvm(335):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
06-01 16:25:33.976: I/dalvikvm(335):   at java.lang.Thread.run(Thread.java:1019)
06-01 16:25:33.976: E/dalvikvm(335): VM aborting
</code></pre>
