Android WebView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android WebView class.

This code example shows how to use the following methods:loadUrl
	} 
	 
	/* Return Base64 Encoded String to Javascript */ 
	public void processPicture( String js_out )
	{		 
		mAppView.loadUrl("javascript:navigator.camera.win('" + js_out + "');");			
	} 
	 
	public void failPicture(String err)
	{ 
		mAppView.loadUrl("javascript:navigator.camera.fail('" + err + "');");
	} 
	 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getContext, loadDataWithBaseURL, setBackgroundColor, setWebViewClient
	} 
	 
	 
    private void setup(){ 
    	 
    	String source = getSource(wv.getContext());
    	String html = source.replace("@src", url).replace("@color", Integer.toHexString(color));
    	 
    	wv.setWebViewClient(this);
    	 
    	//wv.setInitialScale(100); 
    	wv.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
    	wv.setBackgroundColor(color);
    	 
    } 
	 
    private void done(WebView view){
    	if(progress != null){
			//progress.setVisibility(View.GONE); 
			view.setVisibility(View.VISIBLE);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setId, setLayoutParams
    if ((row == null) || (row.findViewById(1337) == null)) {
      RelativeLayout layout = new RelativeLayout(activity);
      layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, ListView.LayoutParams.WRAP_CONTENT));
      row = layout;
       
      WebView webView = new WebView(activity);
      webView.setId(1337);
      RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); 
      float scale = activity.getResources().getDisplayMetrics().density;
      boolean leftPadding = (parent.getTag().equals("right"));
      params.setMargins((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(0 * scale), (int)(20 * scale), 0);
      webView.setLayoutParams(params);
      layout.addView(webView);
    } 
       
    WebView webView = (WebView)row.findViewById(1337);
 
    String item = (String)getItem(position);
    if (item.trim().length() == 0) {
      webView.loadData("<em>No information.</em>", "text/html", "utf-8");
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSettings, loadUrl, setWebViewClient
		super(activity);
 
		this.setTitle("Changelog");
 
		 
		WebView 	view 	 = new WebView(activity);
		WebSettings settings = view.getSettings();  
         
		settings.setJavaScriptEnabled(true);  
		settings.setAppCacheEnabled(false);
         
		view.setWebViewClient( new WebViewClient() {
			@Override 
			public void onPageStarted( WebView view, String url, Bitmap favicon ) {
				if( mLoader == null )
					mLoader = ProgressDialog.show( activity, "", "Loading changelog ..." );
				 
				super.onPageStarted(view, url, favicon);
			} 
 

10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:canGoBack, goBack
  } 
 
  @Override 
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      if (webView.canGoBack()) {
        webView.goBack();
        return true; 
      } 
    } 
    return super.onKeyDown(keyCode, event);
  } 
 
  private final class HelpClient extends WebViewClient {
    @Override 
    public void onPageFinished(WebView view, String url) {
      setTitle(view.getTitle());
      backButton.setEnabled(view.canGoBack());
    } 
 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSettings, restoreState, setWebViewClient
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
     
    WebView browser=getBrowser();
     
    browser.setWebViewClient(new RedirectFixer());
    browser.getSettings().setJavaScriptEnabled(true);
     
    if (savedInstanceState!=null) {
      browser.restoreState(savedInstanceState);
    } 
    else if (urlToLoad!=null) {
      loadUrl(urlToLoad);
    } 
  } 
   
  @Override 
  public void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
     
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:x 1
    			byte buff[] = new byte[rawData.length];
    			in.read(buff, 0, buff.length);
    			out.write(buff, 0, rawData.length);
    			out.flush();
    			out.close();    			
    			mView.loadUrl("javascript:navigator.file.winCallback('File written')");
    		} catch (Exception e) { 
    			mView.loadUrl("javascript:navigator.file.failCallback('Fail')"); 
    		} 
		return 0; 
    } 
     
 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadUrl
	} 
 
	public void onSensorChanged(SensorEvent event) {
		// We want to know what temp this is. 
		float temp = event.values[0];
		mAppView.loadUrl("javascript:gotTemp(" + temp + ")");
	} 
 
} 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSettings, setWebViewClient
 
	@Override 
	public void onActivityCreated(final Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		final WebView view = getWebView();
		view.setWebViewClient(new DefaultWebViewClient(getActivity()));
		final WebSettings settings = view.getSettings();
		settings.setBuiltInZoomControls(true);
		settings.setJavaScriptEnabled(true);
		WebSettingsAccessor.setAllowUniversalAccessFromFileURLs(settings, true);
	} 
 
	public static class DefaultWebViewClient extends WebViewClient {
 
		private final Activity mActivity;
		private final SharedPreferences mPreferences;
 
		public DefaultWebViewClient(final Activity activity) {
			mActivity = activity;
			mPreferences = activity.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addJavascriptInterface
      super.onConfigurationChanged(newConfig);
    }  
     
    private void bindBrowser(WebView appView)
    { 
    	gap = new PhoneGap(this, appView);
    	geo = new GeoBroker(appView, this);
    	accel = new AccelListener(this, appView);
    	launcher = new CameraLauncher(appView, this);
    	mContacts = new ContactManager(this, appView);
    	fs = new FileUtils(appView);
    	netMan = new NetworkManager(this, appView);
    	mCompass = new CompassListener(this, appView);
    	 
    	// This creates the new javascript interfaces for PhoneGap 
    	appView.addJavascriptInterface(gap, "DroidGap");
    	appView.addJavascriptInterface(geo, "Geo");
    	appView.addJavascriptInterface(accel, "Accel");
    	appView.addJavascriptInterface(launcher, "GapCam");
    	appView.addJavascriptInterface(mContacts, "ContactHook");

8
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android WebView Questions & Answers:

Other Android WebView Examples

9:	public class DisPlayWebPageActivity extends Activity {
10:		
11:		WebView webview;
12:		
13:		@Override
-
19:			String page_url = in.getStringExtra("page_url");
20:			
21:			webview = (WebView) findViewById(R.id.webpage);
22:			webview.getSettings().setJavaScriptEnabled(true);
23:			webview.loadUrl(page_url);
-
37:		private class DisPlayWebPageActivityClient extends WebViewClient {
38:		    @Override
39:		    public boolean shouldOverrideUrlLoading(WebView view, String url) {
40:		        view.loadUrl(url);
41:		        return true;

Read More

See Code Examples for Android WebView Methods: