Created
December 5, 2014 10:34
-
-
Save freakynit/d90137c0066c4d90382a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Temp extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
wv = (WebView) findViewById(R.id.webView1); | |
wv.getSettings().setJavaScriptEnabled(true); | |
// register class containing methods to be exposed to JavaScript | |
JSInterface = new JavaScriptInterface(this); | |
wv.addJavascriptInterface(JSInterface, "Android"); | |
} | |
final class JavaScriptInterface { | |
Context mContext; | |
JavaScriptInterface(Context c) { | |
mContext = c; | |
} | |
@JavascriptInterface | |
public void showToast(String message) { | |
Toast.makeText(Temp.this, message, Toast.LENGTH_LONG).show(); | |
} | |
@JavascriptInterface | |
public void showAndroidDialog(String message) { | |
// Some other code | |
} | |
@JavascriptInterface | |
public void moveToScreenTwo() { | |
Intent i = new Intent(Temp.this, NextActivity.class); | |
startActivity(i); | |
finish(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment