packagecom.mzaini30.puasa2018;importandroid.app.Activity;importandroid.content.Intent;importandroid.graphics.Bitmap;importandroid.net.Uri;importandroid.os.Bundle;importandroid.view.KeyEvent;importandroid.view.Window;//import android.view.WindowManager;importandroid.webkit.WebView;importandroid.webkit.WebViewClient;/*
* Demo of creating an application to open any URL inside the application and clicking on any link from that URl
should not open Native browser but that URL should open in the same screen.
*/publicclassPuasa2018ActivityextendsActivity{/** Called when the activity is first created. */WebViewweb;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);this.requestWindowFeature(Window.FEATURE_NO_TITLE);// this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);setContentView(R.layout.main);web=(WebView)findViewById(R.id.webview01);web.setWebViewClient(newmyWebClient());web.getSettings().setJavaScriptEnabled(true);web.loadUrl("file:///android_asset/index.html");}publicclassmyWebClientextendsWebViewClient{@OverridepublicvoidonPageStarted(WebViewview,Stringurl,Bitmapfavicon){// TODO Auto-generated method stubsuper.onPageStarted(view,url,favicon);}@OverridepublicbooleanshouldOverrideUrlLoading(WebViewview,Stringurl){// TODO Auto-generated method stubif(url.contains("http://")||url.contains("https://")){Intenti=newIntent(Intent.ACTION_VIEW,Uri.parse(url));startActivity(i);}else{view.loadUrl(url);}returntrue;}}// To handle "Back" key press event for WebView to go back to previous screen.@OverridepublicbooleanonKeyDown(intkeyCode,KeyEventevent){if((keyCode==KeyEvent.KEYCODE_BACK)&&web.canGoBack()){web.goBack();returntrue;}returnsuper.onKeyDown(keyCode,event);}}