Created
March 4, 2017 16:06
-
-
Save 7fe/6011d2a4e30a4edf946863b9044cdc2c 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
package co.a.ezzylearning; | |
import android.app.Activity; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.webkit.WebChromeClient; | |
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.setClickable(true); | |
w.getSettings().setDomStorageEnabled(true); | |
w.getSettings().setSaveFormData(true); | |
w.getSettings().setAllowContentAccess(true); | |
w.getSettings().setAllowFileAccess(true); | |
w.getSettings().setAllowFileAccessFromFileURLs(true); | |
w.getSettings().setAllowUniversalAccessFromFileURLs(true); | |
w.getSettings().setSupportZoom(true); | |
w.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); | |
w.setWebChromeClient(new WebChromeClient()); | |
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';del();}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