Created
March 4, 2017 09:56
-
-
Save 7fe/e1473af8a3de92b546669c21bb23272c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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