Code example for Thread: Displaying web pages

Methods: getSettingsloadUrlpostUrlsetWebChromeClientsetWebViewClientsleep

-1
		getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
				Window.PROGRESS_VISIBILITY_ON);
		browser = (WebView) findViewById(R.id.browser);
 
		// WebView.enablePlatformNotifications(); 
		browser.setWebViewClient(new BrowserViewClient());
 
		getWindow().addFlags(
				WindowManager.LayoutParams.FLAG_FULLSCREEN
						| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		browser.getSettings().setJavaScriptEnabled(true);
		// browser.getSettings().setBuiltInZoomControls(true); 
		browser.getSettings().setSaveFormData(Boolean.FALSE);
		browser.getSettings().setSavePassword(Boolean.FALSE);
 
		final Activity MyActivity = this;
		browser.setWebChromeClient(new WebChromeClient() {
			@Override 
			public void onProgressChanged(final WebView view, final int progress) {
				MyActivity.setTitle("Cargando, por favor espere...");
				if (progress == 100) {
					MyActivity.setTitle(R.string.app_name);
				} 
			} 
		}); 
 
		final PackageManager pm = getPackageManager();
 
		final IntentFilter filter = new IntentFilter();
		filter.addCategory("android.intent.category.HOME");
		filter.addCategory("android.intent.category.DEFAULT");
 
		final Context context = getApplicationContext();
		final ComponentName component = new ComponentName(context
				.getPackageName(), Block.class.getName());
 
		final ComponentName[] components = new ComponentName[] {
				new ComponentName("com.android.launcher",
						"com.android.launcher.Launcher"), component };
 
		pm.clearPackagePreferredActivities("com.android.launcher");
		pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY,
				components, component);
 
		final CookieManager cookieManager = CookieManager.getInstance();
		final String cookie = cookieManager.getCookie("fiturcastillayleon.com");
 
		if (cookie == null || !cookie.startsWith("SESS")) {
			final String postData = "name=tablet&pass=tablet&form_id=user_login";
			browser
					.postUrl(
							"http://www.fiturcastillayleon.com/feriaturiscyl/user/login", 
							EncodingUtils.getBytes(postData, "BASE64"));
			try { 
				Thread.sleep(2000);
			} catch (final InterruptedException e) {
				// TODO Auto-generated catch block 
				e.printStackTrace();
			} 
			browser.loadUrl(getSharedPreferences("gamePrefs", MODE_PRIVATE)
					.getString(Settings.SETTING_URL,
							getResources().getString(R.string.defaultURL)));
		} else { 
			browser.loadUrl(getSharedPreferences("gamePrefs", MODE_PRIVATE)
					.getString(Settings.SETTING_URL,
							getResources().getString(R.string.defaultURL)));
		} 
 
	} 
Stop searching for code, let great code find you!  Add Codota to your java IDE