155
rated 0 times
[
162]
[
7]
/ answers: 1 / hits: 94467
/ 12 Years ago, sun, may 6, 2012, 12:00:00
I'm trying to start an activity from a javascript interface in my webview.
The example shows a toast. How could i call a class instead of a toast?
public class JavaScriptInterface {
Context mContext;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
public void showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
}
}
this for the html page.
<input type=button value=Say hello onClick=showAndroidToast('Hello Android!') />
<script type=text/javascript>
function showAndroidToast(toast) {
Android.showToast(toast);
}
More From » android