本文整理汇总了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();
}
}
}
示例2: getBrowserTitle
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public String getBrowserTitle(PeerComponent browserPeer) {
synchronized (UiApplication.getEventLock()) {
return ((BrowserField) browserPeer.getNativePeer()).getDocumentTitle();
}
}
示例3: getBrowserURL
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public String getBrowserURL(PeerComponent browserPeer) {
synchronized (UiApplication.getEventLock()) {
return ((BrowserField) browserPeer.getNativePeer()).getDocumentUrl();
}
}
示例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);
}
}
示例5: browserReload
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public void browserReload(PeerComponent browserPeer) {
synchronized (UiApplication.getEventLock()) {
((BrowserField) browserPeer.getNativePeer()).refresh();
}
}
示例6: browserHasBack
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public boolean browserHasBack(PeerComponent browserPeer) {
return ((BrowserField) browserPeer.getNativePeer()).getHistory().canGoBack();
}
示例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();
}
}
示例8: browserBack
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public void browserBack(PeerComponent browserPeer) {
synchronized (UiApplication.getEventLock()) {
((BrowserField) browserPeer.getNativePeer()).back();
}
}
示例9: browserForward
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public void browserForward(PeerComponent browserPeer) {
synchronized (UiApplication.getEventLock()) {
((BrowserField) browserPeer.getNativePeer()).forward();
}
}
示例10: browserClearHistory
import net.rim.device.api.browser.field2.BrowserField; //导入依赖的package包/类
public void browserClearHistory(PeerComponent browserPeer) {
synchronized (UiApplication.getEventLock()) {
((BrowserField) browserPeer.getNativePeer()).getHistory().clearHistory();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
});*/
}