Created
January 23, 2015 15:09
-
-
Save anonymous/30f18702e450f0cdf0fe to your computer and use it in GitHub Desktop.
Android WebView
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
Button button = (Button) findViewById(R.id.button); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.myToolbar); | |
final WebView webView = (WebView) findViewById(R.id.webView); | |
//Set links to show in webview not open in another program. | |
webView.setWebViewClient(new WebViewClient()); | |
Log.d(this.toString(), "Getting settings."); | |
webView.getSettings().setJavaScriptEnabled(true); | |
String url = "http://alexhedley.com/protirus/form.asp"; | |
webView.loadUrl(url); | |
View.OnClickListener listener = new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
String barcode = "barcode"; | |
String fillIn = "document.getElementById('barcode').value = '" + barcode + "';"; | |
String click = "(function(){document.getElementById('btnEnter').click();})()"; | |
String combined = "javascript:" + fillIn + click; | |
webView.loadUrl(combined); | |
} | |
}; | |
button.setOnClickListener(listener); |
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
<android.support.v7.widget.Toolbar | |
android:id="@+id/myToolbar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
/> |
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
<form method="POST" action="form-process.asp"> | |
<label for="barcode">Barcode: </label> | |
<input id="barcode" name="barcode" type="text" value=""> | |
<br /> | |
<input id="btnEnter" name="btnEnter" type="submit" value="Submit"> | |
</form> |
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
<uses-permission | |
android:name="android.permission.INTERNET"> | |
</uses-permission> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment