Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

blackberry - Illegal State Exception when connecting to URL in BrowserField

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

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

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...