WebView addJavascriptInterface - top ranked examples from Open Source projects

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

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
This code example shows how to use the following methods:addJavascriptInterface
    }  
     
    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);
    	fs = new FileUtils(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(fs, "FileUtil");
    } 
         
    /** 
     * Provides a hook for calling "alert" from javascript. Useful for 
     * debugging your javascript. 
7
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadUrl, setLayoutParams, setWebChromeClient
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      //mWebView = (WebView) findViewById(R.id.webView); 
		mWebView = new WebView(this);
 
		mWebView.setLayoutParams(new LinearLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		setContentView(mWebView);
		mWebView.loadUrl("file:///android_asset/www/index2.html");
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.addJavascriptInterface(new MyHybrid(), "MyHybrid");
		mWebView.setWebChromeClient(new WebChromeClient() {
			@Override 
			public void onConsoleMessage(String message, int lineNumber,
					String sourceID) {
				super.onConsoleMessage(message, lineNumber, sourceID);
			} 
		}); 
7
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadUrl, setScrollBarStyle, setWebChromeClient
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        web = new WebView(this);
        web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        setContentView(web);
         
        web.getSettings().setJavaScriptEnabled(true);
        web.getSettings().setAllowFileAccess(true);
        WebViewJavascriptInterface javascriptInterface = new WebViewJavascriptInterface();
        web.addJavascriptInterface(javascriptInterface, "android");
        web.setWebChromeClient(new WebChromeClient());
        web.setWebViewClient(new GenericWebViewClient());
         
        Intent intent = getIntent();
        String contentProviderBaseUri = intent.getStringExtra("base_uri");
        try { 
            server = new HttpServer(6789, "/explorer");

6
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, clearCache, clearFormData, clearHistory, getSettings
	 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
		webView = new WebView(this);
		setContentView(webView);
 
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setDomStorageEnabled(true);
		webView.getSettings().setGeolocationEnabled(true);
		webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
		webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		webView.clearHistory();
		webView.clearCache(true);
		webView.clearFormData();
 
		final Context myApp = this;
 
 

6
CodeRank
This code example shows how to use the following methods:addJavascriptInterface
    }  
     
    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);
    	// This creates the new javascript interfaces for PhoneGap 
    	appView.addJavascriptInterface(gap, "DroidGap");
    	appView.addJavascriptInterface(geo, "Geo");
    	appView.addJavascriptInterface(accel, "Accel");
    	appView.addJavascriptInterface(launcher, "GapCam");
    } 
         
    /** 
     * Provides a hook for calling "alert" from javascript. Useful for 
     * debugging your javascript. 
     */ 
6
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadUrl
	} 
 
	@SuppressLint("SetJavaScriptEnabled") 
	protected void loadURL(String base, String session, String auth) {
		WebView slide = (WebView) getView();
		WebSettings settings = slide.getSettings();
		settings.setJavaScriptEnabled(true);
		settings.setUserAgentString(settings.getUserAgentString() + " "
				+ "/GoOnABoat/1.0"); 
		MainActivity activity = (MainActivity) getActivity();
		slide.addJavascriptInterface(new JsObject(activity), "Android");
		String url = base;
		if (session != null && auth != null) {
			url += session + "?auth=" + auth;
		} 
		Log.i("goonaboat", url);
		slide.loadUrl(url);
	} 
 
	class JsObject { 

6
CodeRank
This code example shows how to use the following methods:getHeight, addJavascriptInterface, getContentHeight, getSettings, x 1
   @Override 
   public void onPageFinished( WebView webView, String url ) {
 
      super.onPageFinished( webView, url );
 
      log.d( "webView.getHeight {0}", webView.getHeight() );
      log.d( "webView.getContentHeight {0}", webView.getContentHeight() );
 
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled( true );
      webView.addJavascriptInterface( new JavaScriptInterface(), JS_BRIDGE );
      webView.loadUrl( JS_CONTENTSIZE );
   } 
 
   public static void loadData( WebView webView, String data ) {
 
      webView.setWebViewClient( new EmbeddedWebView2() );
 
      WebSettings webSettings = webView.getSettings();
      webSettings.setSavePassword( false );
6
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadUrl, setBackgroundColor
This code example shows how to use the following methods:addJavascriptInterface, getSettings, setWebViewClient
    public WebClient(WebView view)
    { 
	super(); 
	if (Build.VERSION.SDK_INT <= 10) {
	    this.view = view;
	    this.view.getSettings().setJavaScriptEnabled(true);
	    this.view.addJavascriptInterface(this.new jsInterface(), "wmpjs");
	    this.view.setWebViewClient(this);
	} 
	moveBuffer = new StringBuilder();
    } 
 
    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url)
    { 
//	android.util.Log.v("console", "OVERRIDEURLLOADING to " + url); 
	view.loadUrl(url);
	return true; 
    } 
 
6
CodeRank

Related WebView addJavascriptInterface Questions & Answers:

addJavascriptInterface Method Overview
Injects the supplied Java object into this WebView.
See Code Examples for other Android WebView Methods: