Search code examples
javagoogle-chromebrowsermozilla

Detecting Which Browser In Java gwt


i'am developping appplication java and i want to know which browser is opened when i launche application?

i found abstract class in gwt Browser :

 package com.google.gwt.query.client;

import com.google.gwt.query.rebind.BrowserGenerator;

/** * This class is the equivalent to the jQuery.browser object in gQuery. * * The implementation is performed by the {@link BrowserGenerator} * * It can be used as a way of deferred-binding without modifying .gwt.xml files, * taking advantage of compiler optimizations which will or will not include the * code in a 'if' statement checking these conditions. * * Example: *

      if (GQuery.browser.ie6) {
        // this code will be removed on non-ie6 permutations 
        Window.alert("IE6");
      } else if (!browser.webkit) {
        // this code will be only in the webkit permutation 
        Window.alert("NOT WEBKIT");
      } 
 * 
* */ public abstract class Browser {

but i don't khnow how to use it


Solution

  • There are multiple ways to do this.

    You can found the user agent by using the native java script

     public static native String getUserAgent() /*-{
          return navigator.userAgent.toLowerCase();
    }-*/;
    

    You can find the user agent using

    Window.Navigator.getUserAgent();