0

In my application I have a log in Screen. When the user enter the correct user name and password I have to collect the information from the website and navigate to main Screen.

I tried following code. But this code is not working. How to achieve it?

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);
    }
}
4

1 に答える 1

1

代わりに

  UiApplication.getUiApplication().pushScreen(new Main());

使用する

 UiApplication.getUiApplication().invokeLater(new Runnable()
                {
                    public void run() 
                    {
                        UiApplication.getUiApplication().pushScreen(new Main());
                    }
                });

あなたはuiスレッドの下でそれをする必要があります。確認してください。

于 2012-08-01T04:51:53.140 に答える