Skip to content

Instantly share code, notes, and snippets.

@7fe
Created March 4, 2017 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7fe/e1473af8a3de92b546669c21bb23272c to your computer and use it in GitHub Desktop.
Save 7fe/e1473af8a3de92b546669c21bb23272c to your computer and use it in GitHub Desktop.
package co.a.ezzylearning;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
private WebView w;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
w = (WebView) findViewById(R.id.activity_main_webview);
w.getSettings().setJavaScriptEnabled(true);
w.getSettings().setBuiltInZoomControls(true);
w.getSettings().setDisplayZoomControls(false);
w.loadUrl("http://dus.tn/music.html");
w.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView w, String url) {
String s = "javascript:"
+ "(function () {"
+ " try{document.body.style.color='blue';}catch(e){}"
+ "})();";
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
w.evaluateJavascript(s, null);
else w.loadUrl(s);
}
});
}
@Override
public void onBackPressed() {
if(w.canGoBack())w.goBack();
else super.onBackPressed();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment