當前位置: 首頁>>代碼示例>>Java>>正文


Java BrowserField類代碼示例

本文整理匯總了Java中net.rim.device.api.browser.field2.BrowserField的典型用法代碼示例。如果您正苦於以下問題:Java BrowserField類的具體用法?Java BrowserField怎麽用?Java BrowserField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BrowserField類屬於net.rim.device.api.browser.field2包,在下文中一共展示了BrowserField類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: browserExposeInJavaScript

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void browserExposeInJavaScript(PeerComponent browserPeer, Object o, String name) {
    synchronized (UiApplication.getEventLock()) {
        try {
            ((BrowserField) browserPeer.getNativePeer()).extendScriptEngine(name, (Scriptable) o);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:10,代碼來源:BlackBerryOS5Implementation.java

示例2: getBrowserTitle

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public String getBrowserTitle(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        return ((BrowserField) browserPeer.getNativePeer()).getDocumentTitle();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例3: getBrowserURL

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public String getBrowserURL(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        return ((BrowserField) browserPeer.getNativePeer()).getDocumentUrl();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例4: setBrowserURL

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void setBrowserURL(PeerComponent browserPeer, String url) {
    if (url.startsWith("jar://")) {
        //ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor();
        //url = "cod://" + ad.getModuleName() +  url.substring(6);
        //super.setBrowserURL(browserPeer, url);
        //url = "local://" + url.substring(6);

        // load from jar:// URL's
        try {
            InputStream i = Display.getInstance().getResourceAsStream(getClass(), url.substring(6));
            if (i == null) {
                System.out.println("Local resource not found: " + url);
                return;
            }
            byte[] buffer = new byte[4096];
            ByteArrayOutputStream bo = new ByteArrayOutputStream();
            int size = i.read(buffer);
            while (size > -1) {
                bo.write(buffer, 0, size);
                size = i.read(buffer);
            }
            i.close();
            bo.close();
            String htmlText = new String(bo.toByteArray(), "UTF-8");
            int pos = url.lastIndexOf('/');
            if (pos > 6) {
                url = url.substring(6, pos);
            } else {
                url = "/";
            }
            String baseUrl = "local://" + url;
            setBrowserPage(browserPeer, htmlText, baseUrl);
            return;
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return;
    }
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).requestContent(url);
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:43,代碼來源:BlackBerryOS5Implementation.java

示例5: browserReload

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void browserReload(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).refresh();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例6: browserHasBack

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public boolean browserHasBack(PeerComponent browserPeer) {
    return ((BrowserField) browserPeer.getNativePeer()).getHistory().canGoBack();
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:4,代碼來源:BlackBerryOS5Implementation.java

示例7: browserHasForward

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public boolean browserHasForward(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        return ((BrowserField) browserPeer.getNativePeer()).getHistory().canGoForward();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例8: browserBack

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void browserBack(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).back();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例9: browserForward

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void browserForward(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).forward();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例10: browserClearHistory

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void browserClearHistory(PeerComponent browserPeer) {
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).getHistory().clearHistory();
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例11: setBrowserPage

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void setBrowserPage(PeerComponent browserPeer, String html, String baseUrl) {
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).displayContent(html, baseUrl);
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例12: browserExecute

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public void browserExecute(PeerComponent browserPeer, String javaScript) {
    synchronized (UiApplication.getEventLock()) {
        ((BrowserField) browserPeer.getNativePeer()).executeScript(javaScript);
    }
}
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:6,代碼來源:BlackBerryOS5Implementation.java

示例13: OAuthScreen

import net.rim.device.api.browser.field2.BrowserField; //導入依賴的package包/類
public OAuthScreen() {
    super(STYLE);

    setFont(Fonts.defaultFont);
    setTitle((Field) null);

    BrowserFieldConfig mConfig = new BrowserFieldConfig();
    mConfig.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);
    mConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
    mConfig.setProperty(BrowserFieldConfig.USER_SCALABLE, Boolean.TRUE);
    mConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE, BrowserFieldConfig.NAVIGATION_MODE_POINTER);
    mConfig.setProperty(BrowserFieldConfig.VIEWPORT_WIDTH, new Integer(Display.getWidth()));

    mConfig.setProperty(BrowserFieldConfig.CONNECTION_FACTORY, createConnectionFactory());

    BrowserField browser = new BrowserField(mConfig);
    add(browser);

    String oauthUrl = "https://oauth.vk.com/authorize?" +
            "client_id=" + Configuration.CLIENT_ID + "&" +
            "scope=" + Configuration.SCOPE + "&" +
            "redirect_uri=" + Configuration.REDIRECT_URL + "&" +
            "display=wap&" +
            "v=" + Configuration.API_VERSION + "&" +
            "response_type=token"; // + (DeviceInfo.isSimulator() ? ";deviceside=true" : "");

    final String accessTokenParamName = "access_token";
    final String userIdParamName = "user_id";
    final String secretParamName = "secret";

    browser.addListener(new BrowserFieldListener() {

        public void documentLoaded(BrowserField browserField, Document document) throws Exception {
            String url = document.getDocumentURI();
            if (url.startsWith(Configuration.REDIRECT_URL)) {
                Array params = new Array(StringUtils.split(url.substring(Configuration.REDIRECT_URL.length() + 1), "&"));

                String accessTokenParam = (String) params.firstOrNull(Predicates.startsWith(accessTokenParamName));
                String userIdParam = (String) params.firstOrNull(Predicates.startsWith(userIdParamName));
                String secretParam = (String) params.firstOrNull(Predicates.startsWith(secretParamName));

                if (accessTokenParam != null && userIdParam != null) {
                    String accessToken = accessTokenParam.substring(accessTokenParamName.length() + 1);
                    String userId = userIdParam.substring(userIdParamName.length() + 1);
                    String secret = secretParam.substring(secretParamName.length() + 1);
                    accessTokenReceived(accessToken, userId, secret);
                }
            }
        }

    });

    browser.requestContent(oauthUrl);

/*browser.setDebugger(new BrowserFieldDebugger() {

  public void pageCompletedLoading(String url) {
    

    super.pageCompletedLoading(url);
  }
});*/
}
 
開發者ID:yanex,項目名稱:vika,代碼行數:64,代碼來源:OAuthScreen.java


注:本文中的net.rim.device.api.browser.field2.BrowserField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。