在我的应用程序中,我有一个登录屏幕。当用户输入正确的用户名和密码时,我必须从网站收集信息并导航到主屏幕。
我尝试了以下代码。但是这段代码不起作用。如何实现?
public final class MyScreen extends MainScreen {
public MyScreen() {
BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);
BrowserField browserField = new BrowserField(myBrowserFieldConfig);
BrowserFieldListener list = new BrowserFieldListener() {
public void documentLoaded(BrowserField browserField, Document document) throws Exception {
String url = document.getBaseURI();
String val = "http://demo.....";
//i am checking the correct url and i will navigate to main screen
if (url.equals(new String(val))) {
UiApplication.getUiApplication().pushScreen(new Main());//here i got IllegalStateException ..
}
System.out.println(" Login URL " + url);
//super.documentLoaded(browserField, document);
}
};
browserField.addListener(list);
add(browserField);
String URL = "http://demo.....";
if (DeviceInfo.isSimulator()) {
URL = URL + ";deviceSide=true";
}
browserField.requestContent(URL);
}
}