I'm illegalStateException

I try to extract the contents of an xml using the code below but it opens the screen at first, then gets a wen illegalstateException that he tries to get the XML

Please advice

package main45;

Import artistapp.main.TextBitmapManager;

import java.io.IOException;
import java.io.InputStream;
Import javax.microedition.io.Connector;
Import javax.microedition.io.HttpConnection;
Import javax.microedition.xml.rpc.Element;

to import org.W3C.DOM.document;
Import org.w3c.dom.Node;
Import org.w3c.dom.NodeList;
Import org.xml.sax.SAXException;

Import net.rim.device.api.system.Bitmap;
Import net.rim.device.api.ui.Field;
Import net.rim.device.api.ui.FieldChangeListener;
Import net.rim.device.api.ui.UiApplication;
Import net.rim.device.api.ui.component.Dialog;
Import net.rim.device.api.ui.component.LabelField;
Import net.rim.device.api.ui.component.RichTextField;
Import net.rim.device.api.ui.component.SeparatorField;
Import net.rim.device.api.ui.container.HorizontalFieldManager;
Import net.rim.device.api.ui.container.MainScreen;
Import net.rim.device.api.xml.parsers.DocumentBuilder;
Import net.rim.device.api.xml.parsers.DocumentBuilderFactory;
Import net.rim.device.api.xml.parsers.ParserConfigurationException;

public class airmainscreen extends screen implements {FieldChangeListener}

Private AboutButtonField aboutbutton;
Private EventsButtonField eventbutton;
Private VideoButtonField videobutton;
Private UpdatesButtonField updatesbutton;
 
 
connection of load
HttpConnection hc = null;
Element = null;
Gross StringBuffer = new StringBuffer();
String temp;
String rd;
Channel file;
Paper chain;
String lenx;
String parentName;
 
public AirMainScreen() {}
TODO auto-generated constructor stub
Bitmap bm = Bitmap.getBitmapResource("images/icons/video.png");
  
Lf channel = "ally Lilly |" Bio;
TextBitmapManager hm = new TextBitmapManager (lf, WB);
setTitle (hm);
  
  
  
buttons
HorizontalFieldManager hmanager = new HorizontalFieldManager();
aboutbutton = new AboutButtonField ("About", 0);
aboutbutton.setChangeListener (this);
hmanager. Add (aboutbutton);
  
videobutton = new VideoButtonField("Video",0);
videobutton.setChangeListener (this);
hmanager. Add (videobutton);

eventbutton = new EventsButtonField("Events",0);
eventbutton.setChangeListener (this);
hmanager. Add (eventbutton);
  
updatesbutton = new UpdatesButtonField("Updates",0);
updatesbutton.setChangeListener (this);
hmanager. Add (updatesbutton);
  
  
  
Add to the center manager
CenterManager cmanager2 = new CenterManager();
cmanager2.setbackground (BackgroundFactory.createLinearGradientBackground (0x9966FF, 0x9999CC, 0x9966FF, 0x9999CC));
  
cmanager2. Add (hmanager);
Add (cmanager2);
  
Add (new SeparatorField());
  
Thread t = new HttpFeed();
t.Start ();
  
  
}
 
 
 
void displayNode (node node, int depth)
{
{if(node==null)}
UiApplication.getUiApplication () .invokeLater (new Runnable() {}

public void run() {}
TODO self-generating method stub
Dialog.Alert ('no');
}
    
});

}
  
  
If (node.getNodeType () is Node.ELEMENT_NODE)
{
StringBuffer buffer = new StringBuffer();
indentStringBuffer (buffer, depth);
NodeList childNodes = node.getChildNodes ();
int numChildren = childNodes.getLength ();
FirstChild node = childNodes.item (0);
 
If the node has only one child and that child is a text node, it is
the form of text, so print '= 'Text' element'.
   
If (numChildren == 1 & firstChild.getNodeType () == Node.TEXT_NODE)
{
     
   
buffer. Append (firstChild.getNodeValue ());
buffer. Append ("\n");
Add (new RichListFieldx (buffer.toString (), 0));
Add (new SeparatorField());
   
}
on the other
{
  
parentName = node.getNodeName ();
 
for (int i = 0; i)< numchildren;="" ++i="">
{
displayNode (childNodes.item (i), depth + 1);
}
}
}
on the other
{
 
String nodeValue = node.getNodeValue ();
If (nodeValue.trim () .length ()! = 0)
{
StringBuffer buffer = new StringBuffer();
indentStringBuffer (buffer, depth);
buffer. Append (' "") .append (nodeValue) .append ("'");
Add (new RichTextField (buffer.toString ()));
}
}
}

' Public Sub fieldChanged (field field, int context) {}
TODO self-generating method stub
 
  
}

class HttpFeed extends Thread {}

HttpConnection hc = null;
InputStream is;
RootElement element;
Document document = null;
 
public HttpFeed() {}
TODO auto-generated constructor stub
}
 
 
public void run() {}
try {}
HC = (HttpConnection), Connector.open ("path-to-xml");
hc.setRequestMethod (HttpConnection.GET);
hc.setRequestProperty ("Content-Type", "plain of //text");
Final InputStream is = hc.openInputStream ();
final int len = (int) hc.getLength ();
mutable int ok = hc.getResponseCode ();
final String rm = hc.getType ();
  
 
  
Unwrap the xml
DocumentBuilderFactory plant = DocumentBuilderFactory.newInstance ();
DocumentBuilder builder = null;
try {}
Builder = factory.newDocumentBuilder ();
} catch (ParserConfigurationException e) {}
Generative TODO catch block
e.printStackTrace ();
}
HC = (HttpConnection) Connector.open (url + "; deviceside = true");
hc.setRequestMethod (HttpConnection.GET);
InputStream inputStream = hc.openInputStream ();
file = hc.getFile ();
try {}
Document document = builder.parse (is);
LenX = document. GetElementsByTagName ("to"). Item (0) .getChildNodes (). Item (0) .getNodeValue ();

org. W3C. DOM. Element rootElement = document.getDocumentElement ();
rootElement.normalize ();
Generative TODO catch block
    
        
displayNode (rootElement, 0);

} catch (SAXException e) {}
Generative TODO catch block
e.printStackTrace ();
}
HC. Close();
is. Close();

} catch {} (final IOException e1)
Generative TODO catch block
UiApplication.getUiApplication () .invokeLater (new Runnable() {}
public void run()
{
Dialog.Inform (E1.getMessage ());
System.out.Print (E1.getMessage ());
}

});
  
}
 
 
}
   
 
 
}

}

It is useful to use the Debug lines like the following. :

try {}

} catch (Throwable t) {}

Code that could be a mistake

t.printStackTrace ().

System.out.println ("Exception" + t.toString ());

{

This will tell you what really is the Exception.

In this case, I am convinced, that it is because you are trying to update the User Interface of a Thread that is not the thread of events.  It is a common problem, and there are discussions in this forum dealing with this.  I suggest rather than repeat myself this information, looking around.  There is also a video that addresses the event Thread I think, you might find useful.

Tags: BlackBerry Developers

Similar Questions

  • IllegalStateException during the loading of a screen

    Me once again. Don't worry, I've almost finished my app and I'm leaving for a nice weekend well-deserved tomorrow morning early

    anyway. On my first screen I call this code:

       public void fieldChanged(Field field, int context) {
            // TODO Auto-generated method stub
             if(field == ContactButton)
                {
    
                 UiApplication.getUiApplication().pushScreen(new Contact());
                }
             else if (field == DownloadButton)
             {
                    UiApplication.getUiApplication().pushScreen(new DownloadScreen());
    
             }
    
        }
    

    On my Contact button, when pressed, I get IllegalStateException. The download button is displayed and ListField events work fine

    What can be wrong?

    Hannes

    you add title twice comment both this setTitle (title); in your code

    We you add in optimizing resources like this (title) vfm.add;
    and second setTitle (title);

  • IllegalStateException when inserting in a Manager.

    Hello!

    I'm trying to insert a field into a thread Manager.

    More details: the Manager in question is in fact a RichList class - as I wrote for the devices 'preBBOS7 '. Here it is:

    package crapsnap;
    
    import net.rim.device.api.command.Command;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.EncodedImage;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.HorizontalFieldManager;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    
    public class RichListField extends VerticalFieldManager {
    
        private Command cmd = null;
        private boolean _imageSpaceUsed;
        private int _numberOfLabelFields;
        private int _numberOfDescriptionFields;
        private boolean alternened = false;
    
        RichListField(Manager manager, boolean imageSpaceUsed,
                int numberOfLabelFields, int numberOfDescriptionFields) {
            _imageSpaceUsed = imageSpaceUsed;
            _numberOfLabelFields = numberOfLabelFields;
            _numberOfDescriptionFields = numberOfDescriptionFields;
            this.setBackground(BackgroundFactory.createBitmapBackground(EncodedImage.getEncodedImageResource("empty.png").getBitmap()));
            manager.add(this);
        }
    
        public int getFocusRow() {
            for (int i = 0; i < this.getFieldCount(); i++) {
                if (this.getField(i).isFocus() == true) {
                    return i;
                }
            }
            return -1;
        }
    
        public void setFocusPolicy(int policy) {
            //pas compris l'interet.
            //Juste là pour compatibilité.
        }
    
        public void setCommand(Command command) {
            cmd = command;
        }
    
        public void remove(int row) {
            this.delete(this.getField(row));
        }
    
        public  void insert(int row, Object[] rowObj) {
            this.insert(Factory(rowObj, true), row);
        }
    
        public Object[] get(int row) {
            return ((ListManager) this.getField(row)).arg;
        }
    
        public void add(Object[] rowObj) {
            this.add(Factory(rowObj, false));
        }
    
        protected boolean trackwheelClick(int status, int time) {
            if (cmd.equals(null)) {
                return false;
            } else {
                cmd.execute(this);
                return true;
            }
        }
    
        private Manager Factory(Object[] arg, boolean isupdated) {
    
                int i = 0;
                boolean textfielded = false;
                ListManager Main = new ListManager();
                Main.arg = arg;
                HorizontalFieldManager Head = new HorizontalFieldManager();
                VerticalFieldManager Label = new VerticalFieldManager();
                VerticalFieldManager Description = new VerticalFieldManager();
                if (_imageSpaceUsed == true) {
                    Head.add(new BitmapField((Bitmap) arg[0]));
                    i = i + 1;
                }
                for (int j = 0; j < _numberOfLabelFields; j++) {
                    if (textfielded == false){
                        LabelField txt = new LabelField((String) arg[i] + "                                                                                         ",Field.FOCUSABLE);
                        Label.add(txt);
                        textfielded = true;
                    } else {
                    Label.add(new LabelField((String) arg[i]));
                    }
                    i = i +1;
                }
                Head.add(Label);
                Main.add(Head);
                for (int k = 0; k < _numberOfDescriptionFields; k++) {
                    Description.add(new LabelField((String) arg[i]));
                    i = i+1;
                }
                Main.add(Description);
                if (isupdated == false){
                    if (alternened == true){
                    Main.setBackground(BackgroundFactory.createSolidBackground(Color.IVORY));
                    alternened = false;
                } else {
                    Main.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
                    alternened = true;
                }
                }else {
                    Main.setBackground(BackgroundFactory.createSolidBackground(Color.ANTIQUEWHITE));
                }
    
                return Main;
        }
    
        private class ListManager extends VerticalFieldManager {
    
            public Object[] arg;
    
            ListManager() {
                super(Manager.NO_HORIZONTAL_SCROLL );
            }
    
        }
    }
    

    It is used in the form of my application. The problem come when I try to update the screen of tread has launched in a separate category. Here it is:

    public void  run() {
                try {
                    Thread.sleep(10);
                    ReceveirString = Recipent + "";
                    _viewSnap.Snaplist.insert(6, new Object[] { _viewSnap._0img,
                            "" + ReceveirString, "Sending..." });
                    _viewSnap.offsetint++;
                    _viewSnap.Vectoroffset = _viewSnap.Vectoroffset + receiver;
                    if (friendselector.IsStoryed() == true) {
                        Thread.sleep(10);
                        if (API.SendStory(encryptedImg, 0, Recipent,
                                Current.getString("username"),
                                Current.getString("auth_token"), time) == true) {
                            _viewSnap.Snaplist.remove(6);
                            _viewSnap.Snaplist.insert(6,
                                    new Object[] { _viewSnap._0img, "" + ReceveirString,
                                            "Moment ago..." });
                            return;
                        }
                    } else {
                        Thread.sleep(10);
                        if (API.SendSnap(encryptedImg, 0, Recipent,
                                Current.getString("username"),
                                Current.getString("auth_token"), time) == true) {
                            _viewSnap.Snaplist.remove(6);
                            _viewSnap.Snaplist.insert(6,
                                    new Object[] { _viewSnap._0img, "" + ReceveirString,
                                            "Moment ago..." });
                            return;
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    ReceveirString = Recipent + "";
    
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
    

    I take the screen containing my RichList in parameter, which is the _viewsnap (and snaplist is my manager on the inside). But when I do that, I get 'IllegalStateException'... don 't know why. Any idea?

    invokeLater allows access to the user interface in a separate thread.

    See
    http://supportforums.BlackBerry.com/T5/Java-development/what-is-the-event-thread/Ta-p/446865

  • java.lang.IllegalStateException: no application on HttpConnection instance

    Hello.

    I IllegalStateException when you try to send data to the server.

    Same good code worked on the application of another.
    What is c?

    Thanks for the quck response. I find the solution.

    I have replace HttpConnection of principal on another method and it works.

  • Locator.geocode thorws IllegalStateException

    I want to have the latitude and longitude of an address, and I used

    Locator.geocode

    but it throws IllegalStateException, application is made on the event dispatch thread

    How can I solve this?

    is possible to use Locator.geocode in my application, because if I use Locator.geocode anywhere in the source it throws an exception,

    Since the javadocs:

    An application must ask geocode information outside the event sending thread.

    Start a worker thread, and make the call to the thread.

  • Avoiding IllegalStateException with inactive screens

    I tried to avoid the IllegalStateExceptions... like a n00b I get them pretty often. I realized doing something on the screen the user jumped (bad, bad!) often gives an illegal state. I tried to write a method to detect if the screen is higher up in the stack, so I check first before doing anything on the screen, so if I do anything in a thread and have to come back later, I check if the screen is active, first.

    {} public boolean isActive()
    return UiApplication.getUiApplication () .getActiveScreen () is this;
    }

    I realized a few questions/issues with this approach.

    • If the user has the menu open... This code considers that the screen be IN-active, so my code won't do anything while the menu is open
    • I'd get an illegal state if I try to touch the screen below the menu when the user has a menu open? If Yes, this means I would have if sit and wait until the screen activates before I run the code after that I'll be back on the wire?
    • Would I be better to copy the invokeLater, runnables tail model, and then run then when screen is active? As in, the implementation of ScreenUiEngineAttachedListener and then try something like this below...

    protected void invokeWhenActive (Runnable r) {}

    store the executable

    }

    public void onScreenUiEngineAttached (attached screen, boolean) {}

    {if (attached)}

    check if we have pending runnables...

    UiApplication.getUiApplication () .invokeLater (runnable);

    }

    }

    What best practices can I keep in the spirit of updating the screens? To give a concrete example. Users select a category of points of interest (for example, police station, hospital) of a screen then I press the display of the result list that begins with the display of a loading animation. Then it will update when I get the info.

    IllegalStateException may actually occur for various reasons.  But that being said, I'm not aware of any that are the result of a screen is not not the active screen.  So I suspect your presumption that it is the cause is not correct, I think that there is something else that goes along with the screen being burst that creates your problem.

    I usually print the exception (. toString()) to know exactly why I got it.  You will find examples of this kind of thing

    (a) you can get this by setting the focus on a field that is not actually on the screen - I think that the message will say something about "not apparent" or "not on the screen" (note that you can set the Focus on a field for a screen that is NOT on the top of the stack)

    (b) adding a field to a Manager when the field is already added to a Manager, I think the message will say "already apparent.

    So unless you print the detailed message, you will not be able to solve your problem.

    Regard to deliver you from editing screen, don't forget not that when you update a screen, you must have the lock on the event - that's all just a lock that makes sure that only one thing is updating the user interface at the same time.  Now all the event handlers (menu key, etc.) running on the event Thread, which means that they all have the lock.  You can take advantage of that too.  You can plan a Runnable t run on the thread of events, when he has the lock on the event.  To do this, use this "incantation":

    (UiApplication.getUiApplication), invokeLater (new Runnable() {}

    public void run() {}

    your UI code update

    }

    });

    Thus, you should use this kind of process when you get the information you want.  Then push the ' loading screen, start your thread to download, have the wire download use this incantation to display the loading screen, and update the user interface.

    Hope that answers the following questions:

    See more here:

    http://supportforums.BlackBerry.com/T5/Java-development/what-is-the-event-thread/Ta-p/446865

    http://supportforums.BlackBerry.com/T5/Java-development/blocking-operation-not-permitted-on-event-di...

  • BrowserField IllegalStateException to call the RequestContent method

    Hello world.

    I'm IllegalStateException when you try to view another page HTML on my BrowserField. This happens when BrowserField Manager calls the removeField() method.

    The paper said: to remove is field with focus - index: 0 - fieldDebugTree: net.rim.device.api.ui.component.NullField (0, 0) + (0, 0) * home * \n - managerDebugTree: net.rim.device.api.browser.field2.BrowserField (0, 0) + (480, 70) [480, 70] \n net.rim.device.api.ui.component.NullField (0, 0) + (0, 0) \n

    Everyone knows that kind of problem before?

    Thanks before.

    Never mind. I found the solution to this problem after doing some more research on this forum.

    Here is the link to the post with the solution: http://supportforums.blackberry.com/t5/Java-Development/BrowserField-refresh-throwing-IllegalStateEx...

  • IllegalStateException when adding label to the screen from timertask

    Hello

    I have a thread that gets the text for a labelfield. I just want to add the labelfield on-screen when the thread is finished.

    I have a timertask that checks when the thread is finished and when the thread is finished, he tries to add the label to the form.

    This is the code, but when I try to add the label I get illegalstateexception-

    GTC GetContent = new GetContent();
    t = new Thread (gtc);
    t.Start ();
                
    Timer = new Timer();
    timer.scheduleAtFixedRate (new TimerTask() {}
    public void run() {}
    {if (! t.IsAlive ())}
    Timer.Cancel ();
    Test string = t.getTextLabel ();
    addLabel (new LabelField (test));
    }
    }
    Invalidate();
    }
    (}, 1000, 1000);

    }
            
    Private Sub addLabel (LabelField l) {}
    Add (l);
    }

    If she runs in an external thread to wrap it in an invokelater (or the synchronization on the eventlock).

    You can check the exceptions by surrounding the code with a try/catch.

  • IllegalStateException then add the previously deleted field

    Code snippet that fails:

    /** * Depending on the value of homeScreen.mNumberEditField, the * mHomeScreen.myTextField is removed or re-added after being * removed.  Does not work, when re-added an IllegalStateException * is thrown. */class MyEditFieldChangeListener implements FieldChangeListener {
    
        HomeScreen mHomeScreen;
    
     // the default state, where the mytextfield is showing    int STATE_DEFAULT = 1;
    
      // we've removed the mytextfield  int STATE_MY_TEXTFIELD_REMOVED = STATE_DEFAULT + 1;
    
     // current state  int curState = STATE_DEFAULT;
    
     public NumberEditFieldChangeListener(HomeScreen homeScreen)   {     super();      mHomeScreen = homeScreen; }
    
       public void fieldChanged(Field field, int context)    {     if (context == PROGRAMMATIC)      {         // ignore "programmatic changes", whatever that means.            return;       }
    
           if (field == homeScreen.mNumberEditField) {
    
             int len = homeScreen.mNumberEditField.getTextLength();            switch (len)          {         case 0:
    
                 if (curState == STATE_MY_TEXTFIELD_REMOVED)               {                 // throws IllegalStateException.                  mHomeScreen.add(mHomeScreen.myTextField);                 curState = STATE_DEFAULT;             }
    
                   break;            default:              // is it numeric?             if (isNumeric() == false)             {
    
                       // remove call log fields                 if (curState == STATE_DEFAULT)                    {                     mHomeScreen.delete(mHomeScreen.myTextField);
    
                            curState = STATE_MY_TEXTFIELD_REMOVED;                    }
    
                   }             break;            }     }
    
       }
    
    }
    

    I found a solution that seems to work:

    Instead of the call

    mHomeScreen.add(mHomeScreen.myTextField);
    ...
    mHomeScreen.delete(mHomeScreen.myTextField);
    

    I tried to use

    mHomeScreen.getMainManager().add(mHomeScreen.myTextField);
    ..
    mHomeScreen.getMainManager().delete(mHomeScreen.myTextField);
    

    and the error disappeared.

  • IllegalStateException

    I'm having a Manager and I'm trying to add the field separator to the manager as the first field. It gives IllegalStateException.

    And also field added to a Manager, while it is already apparent.  message is coming.

    My code is like that.

    LoginManager VerticalFieldManager = new VerticalFieldManager (VerticalFieldManager.NO_VERTICAL_SCROLLBAR);

    SeparatorField lineField = new SeparatorField();

    loginManager.add (lineField);       This seems to be the problem

    Am I missing something.

    Thanks for any help.

    To sum this up, you add the same component to more than one Manager/screen... IllegalStateException is for adding the component (Field) even for the second time and the second mistake is to add a different Manager (or its derivative)...

    See you soon... You can paste the code?

  • IllegalStateException in OptionsProvider

    I created an options page to my application using the example of "how - to add application options to the BlackBerry Options. Loading and saving worked fine, but when I opened the page a second time it crashes with IllegalStateException. It's already been resolved, but I don't know the reason.

    private RichTextField text_allow;
    //Will crash program
    //private RichTextField text_allow=new RichTextField("Allow connections:",Field.NON_FOCUSABLE);
    
    public void populateMainScreen(MainScreen screen){
            optionsProperties=SMOptionsProperties.getSMOP();
    
            //works when initialised here
            text_allow=new RichTextField("Allow connections:",Field.NON_FOCUSABLE);
            screen.add(text_allow);
    
            //other things omitted
        }//populatrMainScreen
    

    Is this something to do with

    //Null out our member variables so that their objects can be garbage
    //collected. Note that this instance continues to be held by the
    //options manager even after the user exits the options app,
    //and will be re-used next time.
    

    If I have nothing to text_allow, NullPointerException is thrown.

    If I have not, IllegalStateException.

    Whenever an Options screen, is called populateMainScreen, and creates a new instance of the screen.  This means that you also have to create a new instance of your fields to add to this new instance of the form.

    A field can only be added to a single screen.  By instantiating text_allow outside the populateMainScreen you re - use the instance of this field, which does not work.

  • IllegalStateException uncaught

    I want to add previous and before the button for the command of the "BrowserField" in my application. But often it gives ' JVM error 104: eception IllegalStateException "for education"browserFieldHistory.goBack ()"and"browserFieldHistory.goForward ()".

    private final class ButtonListener implements {FieldChangeListener}
    ' Public Sub fieldChanged (field field, int context) {}

    ........

    if(Field == backButton) / / return
    {
    try {}
    browserFieldHistory = getBrowserField () .getHistory ();
    If (browserFieldHistory.canGoBack ())
    {
    try {}
                            browserFieldHistory.goBack ();
    } catch (IllegalStateException e) {}
    Log.info ("js:back() runtime error :"); ")
    }
    }
    } catch (IllegalStateException e) {}
    Log.info ("js:back() runtime error :"); ")
    }
    }
    if(Field == ForwardButton) / / advance
    {
    try {}
    browserFieldHistory = getBrowserField () .getHistory ();
    If (browserFieldHistory.canGoForward ())
    {
    try {}
                                browserFieldHistory.goForward ();
    } catch (IllegalStateException e) {}
    }
    }
    } catch (IllegalStateException e) {}
    Log.info ("js:next() runtime error :"); ")
    }
    }
    }
    }

    Although the statement are in the "try-catch" with IllegalStateException handling, he still throws uncaught exception. Can someone point out an error in my code?

    As an experiment, set the focus on the BrowserField before doing this.

    try {}
                            browserFieldHistory.setFocus ();

    browserFieldHistory.goBack ();

  • IllegalStateException when closing a screen in its constructor (single-threaded application)

    I use a screen that displays a list of items. The builder checks if there is nothing to display and if not, displays a dialog box with a message and call close(). The close() call produces IllegalStateException (on 5 BB). Why and how can I close or the screen?

    BTW, I read on do not call close() in a different thread, but in this case, I do not (at least in my code) any extra thread.

    public class MyScreen extends MainScreen implements ListFieldCallback
    {
      MyScreen()
      {
        super(Manager.NO_VERTICAL_SCROLL);
    
        int count = getItemsCount(); // A method that returns the number of items to display
    
        if (count == 0)
        {
          Dialog.inform("No item");
          close(); // throws IllegalStateException
          return;
        }
    
        // More irrelevant stuff here
    
      }
    }
    

    Thank you!

    My point was the call to close as the manufacturer, there is no possible way that the screen can be on the displaystack at the time wherever you call close...

    in another part of your code, you probably:

    uiApplication.pushScreen (new MyScreen());

    Push code will not happen before the end...

  • Addition of locationPicker throws IllegalStateException

    Thread [Ritis_Maps(180)id=253124608] (Suspended (exception IllegalStateException))
        LocationPicker(Screen).setManager(Manager, int) line: 6219
        VerticalFieldManager(Manager).insertInternal(Field, int) line: 2203
        VerticalFieldManager(Manager).add(Field) line: 545
        TitleStatusManager.add(Field) line: 609
        AdvancedIncidentListOptions(Screen).add(Field) line: 288
        AdvancedIncidentListOptions.addComponents() line: 147
        AdvancedIncidentListOptions.() line: 93
    

    I have a screen where I add my LocationPicker. I call add (locationPicker);

    I call this method before, to set up the locationPicker.

    private void readyLocationPicker(){
        Vector locationpick = new Vector();
    
        locationpick.addElement(GPSLocationPicker.getInstance());
    
        Landmark[] landmarks = new Landmark[1];
        landmarks[0] = new Landmark("DC Beltway", "Center of 495 Beltway", new QualifiedCoordinates(LATITUDE_CENTER_OF_DC_BELTWAY, LONGITUDE_CENTER_OF_DC_BELTWAY, Float.NaN, Float.NaN, Float.NaN), null);
        final SuggestedLocationPicker slp = SuggestedLocationPicker.getInstance("Suggested Locations...", landmarks);
        locationpick.addElement(slp);
    
        locationpick.addElement(EnterLocationPicker.getInstance(true));
        locationpick.addElement(MapsLocationPicker.getInstance());
        locationpick.addElement(RecentLocationPicker.getInstance());
        locationpick.addElement(ContactsLocationPicker.getInstance(true));
    
        LocationPicker.Picker[] locationPickersArray = new LocationPicker.Picker[locationpick.size()];
        locationpick.copyInto(locationPickersArray);
    
        locationPicker = LocationPicker.getInstance(locationPickersArray);
        locationPickListener = new LocationPicker.Listener() {
    
            public void locationPicked(Picker picker, Landmark location) {
                if(picker==slp){
                    //TODO: Change radius field to 30 Miles
                    choiceRadius.setSelectedValue(30);
                }
                System.out.println("Landmark: " + location);
            }
        };
        locationPicker.setListener(locationPickListener);
    }
    

    I don't know what is happening and why it will not work.

    Thank you.

    Oh, it extends screen. Ridicule me. Here's how I got to work:

    locationPickerButton = new ButtonField("Location", ButtonField.CONSUME_CLICK | ButtonField.FIELD_RIGHT);
    locationPickerButton.setChangeListener(new FieldChangeListener() {
        public void fieldChanged(Field field, int context) {
    
            locationPicker.show();
            locationPickerButton.setLabel(locationPickerLocation.getName());
    
        }
    });
    
  • IllegalStateException to displayContent() on browserfield

    Hello

    I need someone's help.

    I IllegalStateException when calling displayContent() on browserField (os6).

    Thanks in advance

    Hello

    It's my resolution. He is very good at the moment.

    public void in documentCreated (BrowserField browserField,
    ScriptEngine scriptEngine, documents)
    throws Exception {}
    If (document.getBaseURI () .startsWith ('http://www."" ")) {

    Browser.getDefaultSession (.displayPage)
    document.getBaseURI ());
    UiApplication.getUiApplication (.invokeLater)
    new Runnable() {}
    public void run() {}
    Manager manager = ads.getManager ();
    System.out
    .println ("managergggggggggggggg ="
    (+ Manager);
    Manager.Delete (ADS);
    ads = new BrowserField();
    ads.addListener (listener);
    Manager.Add (ADS);
                                       
    ads.displayContent (adsV, "");
    }
    });

    }

    ads.addListener (listener);
    Add (ADS);

    ads.displayContent (adsV, "");

Maybe you are looking for

  • HP PAVILION 2 X 10-N002NL: HP Pavillion X 2 microsd

    Hello. I bought the HP Pavilion 10 - X 2 N002. question: can I use sdxc type microSD? and what is the maximum usable capacity? the hp call center gave me conflicting information and evil: up to 32 GB but I have already tried 64 GB with success. can s

  • Getting property of type 'Date' from a PDO data store

    It is therefore a question of both parties.  Part A: when I search for data in a data store, to find data by using the object Navigator returns the correct number of results, using the object. GetElementList does not work.  I'm looking in the data st

  • Code internet printing HP PSC 2410

    HP PSC 2410 all-in-one XP Pro & XP Home - (2 lapstop - same problem with this printer) No changes have been made to the XP Home, just installed this printer on the XP Pro laptop and it's printing code.

  • Problem of external links

    I upgraded the windows of Big Brother 1.18 to 4.40 client screen and now my external link does not work. The excutues very well on the client, but the server script shows purple. I double check the paths in the script, everything seems fine. Not sure

  • Fault data/internet BlackBerry Smartphones?

    Hello, I just received my bb back from repair, and when I came back it was locked once again to another carrier. I unlocked it with code MEP that the carrier provided and am now running the phone with O2 UK sim card. Im not sure if the above is relav