Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wrote some code to connect to a URL in a BrowserField. In the process its shows Illegal State Exception. If I click Continue, then it connects. I do not understand what is the problem.

Here is the code I am using:

class MoreBrowserScreen extends MainScreen
{
    String email;
    public MoreBrowserScreen(String email)
    {
        this.email=email;
        setTitle(HeaderManager.tabsManager());
        HeaderManager.more.setFocus();
        TabsManager(Paths.HOME,Paths.ALERTS,Paths.COLL,Paths.APP,Paths.FMORE).getTabs();

        BrowserField myBrowserField = new BrowserField();
        add(myBrowserField);

        myBrowserField.requestContent(email);
    }
    protected void makeMenu(Menu menu, int instance)
    {
        MenuItemClass mic = new MenuItemClass();
        menu.add(mic.getExitItem(0, 0));
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
208 views
Welcome To Ask or Share your Answers For Others

1 Answer

Hi I was having same problem, first you need to use invokelater because you are in event thread, and for some mysterious reason also set focus to browser, here is what solved my problem:

 private void buttonClicked() {
  UiApplication.getUiApplication().invokeLater(new Runnable() {         
    public void run() {      
        browser.setFocus();
        browser.requestContent("http://www.blackberry.com/developers" + ";deviceside=true");
    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...