java - Creating An In-Game Web Browser on Android -
in game, i'd have kind of "message of day" feature. basically, when user taps "message of day" button in main menu, open browser view in-game. when user done, taps "close" button , view disappears, returning him game menu.
so, possible create browser view dynamically? if yes, how?
the following can used in dialog
public void setwebview() { //webviewclient used if want capture stuff webview, if link pressed webviewclient yourwebclient = new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { open_web = true; if (!url.startswith("http://") && !url.startswith("https://")) { url = "http://" + url; } intent browserintent = new intent("android.intent.action.view", uri.parse(url)); startactivity(browserintent); return true; } }; webview wv = (webview) findviewbyid(r.id.webview); wv.setwebviewclient(yourwebclient); string str = gethtml(); wv.loaddata(str, "text/html", "utf-8"); wv.setbackgroundcolor(0); } boolean isasset = false; private string gethtml(){ inputstream source = null; if (isasset){ source = getassets().open("motd.html"); } else { source = new fileinputstream(environment.getexternalstoragedirectory() + "motd.html"); } }
Comments
Post a Comment