PopupScreen in an Application

I have a system application that extends the Application and adds a MenuItem in the Contacts menu. Once you click on this istaniates a class which extends screen. This class checks to be sure, there is a correct e-mail address for this contact. Everything is good so far. Once it is determined that the email address is good, then he instaniates a class that extends the PopupScreen and the error occurs. I'm going in the right direction or should I do this differently. I'm relatively new to BB dev. Thank you

Here is the code

class ContactInfo extends UiApplication {}
private static final String ARG_LAUNCH_CONTACT_INFO = "1";
private static ContactInfo above;
       
Public Shared Sub main (String [] args) {}
If (args == null | args.length == 0) {}
This = new ContactInfo("");
ci.enterEventDispatcher ();
} else {}
String appToLaunch = args [0];
If (ARG_LAUNCH_CONTACT_INFO.equals (appToLaunch)) {}
try {}
This = new ContactInfo (appToLaunch);
ci.enterEventDispatcher ();
} catch (IllegalStateException s) {}
Status.Show (s.ToString ());
}
}
}
}
           
public ContactInfo (String param) {}
If (parm.equals("")) {}
long locationToAddMenuItem = ApplicationMenuItemRepository.MENUITEM_ADDRESSBOOK_LIST;
ToolBarMenuButton.AddMenuItem (ARG_LAUNCH_CONTACT_INFO, locationToAddMenuItem, ContactsMenuItem()) new;
System.Exit (0);
} else {}
System.out.println ("start COntactsMenuItem");
new ContactsMenuItem();
}
}

private public static void ToolBarMenuButton.AddMenuItem (String argOfAppl, long location, ApplicationMenuItem applMenuItem) {}
Amir ApplicationMenuItemRepository = ApplicationMenuItemRepository.getInstance ();
ApplicationDescriptor app = ApplicationDescriptor.currentApplicationDescriptor ();
App = new ApplicationDescriptor (app, new String [] {argOfAppl});
amir.addMenuItem (location, applMenuItem, app);
}
   
   
private static class ContactsMenuItem extends ApplicationMenuItem {}
public ContactsMenuItem() {}
Super (200000);
}
       
public String toString() {}
return 'Contact Info';
}
       
public Object execute (object context) {}
BlackBerryContact c = (BlackBerryContact) context;
If (c! = null) {}
Application.getApplication () .requestForeground ();
try {}
System.out.println ("Got a contact");
Ui.getUiEngine () .pushScreen (new MChoices (c));
/ * While (! Barreter) {}
try {}
Thread.Sleep (250);
} catch (InterruptedException e) {}
Dialog.Alert ("Thread interrupted");
}
}*/
} catch (IllegalStateException s) {}
System.out.println ("illegal state error =" + s.getMessage ());
Status.Show (s.ToString ());
}
} else
throw new IllegalStateException ("Context is null, expects an instance of Contact");
Returns a null value.
}
}
   
static class final MChoices extends PopupScreen implements FieldChangeListener {KeyListener
private BlackBerryContact c;
ButtonField private close, update;
Photo exhib CheckboxField, pine, Manager, phone;
private String [] name = new String [3];
private String fullName, email;
                      
public MChoices (contact BlackBerryContact) {}
Super (new FlowFieldManager(), Field.FOCUSABLE |) Field.FIELD_HCENTER);
c = contact;
name = c.getStringArray (BlackBerryContact.NAME, 0);
fullName = name [BlackBerryContact.NAME_FAMILY] + ', ' +.
name [BlackBerryContact.NAME_GIVEN];
System.out.println (FullName);
           
LabelField cont = new LabelField ("Contact:" + fullName, Field.FIELD_HCENTER |) Field.USE_ALL_WIDTH);
Add (cont);
White LabelField = new LabelField ("", Field.USE_ALL_WIDTH);
Add (blank);
Photo = new CheckboxField ("Photo", true, Field.FIELD_LEFT |) Field.USE_ALL_WIDTH);
PIN = new CheckboxField ("spit", true, Field.FIELD_LEFT |) Field.USE_ALL_WIDTH);
Director = new CheckboxField ("Manager", true, Field.FIELD_LEFT |) Field.USE_ALL_WIDTH);
Phone = new CheckboxField ("Phone Info", true, Field.FIELD_LEFT |) Field.USE_ALL_WIDTH);
Add (photo);
Add (pin);
Add (Manager);
Add (Phone);
LabelField blank2 = new LabelField ("", Field.USE_ALL_WIDTH);
Add (blank2);
Update = new ButtonField ("Update Contact", Field.FIELD_HCENTER);
close is new ButtonField ("close", Field.FIELD_HCENTER);.
Add (Update);
Add (Close);
photo.setChangeListener (this);
pin.setChangeListener (this);
manager.setChangeListener (this);
phone.setChangeListener (this);
update.setChangeListener (this);
close.setChangeListener (this);
update.setFocus ();
}
               
' Public Sub fieldChanged (field field, int context) {}
If (field == relatives) {}
This.Close ();
} ElseIf (field == update) {}
If (c.countValues (BlackBerryContact.EMAIL) > 0) {}
updateContact();
} else {}
Dialog.Alert ('no email for Contact');
This.Close ();
}
}
}
       
{public boolean keyStatus (keycode int, int times)
Returns false;
}
       
{public boolean keyRepeat (keycode int, int times)
Returns false;
}
       
{} public boolean keyUp (keycode int, int times)
Returns false;
}
       
{} public boolean keyDown (keycode, int, int times)
Returns false;
}
       
{} public boolean keyChar (key char, int status, int time)
Boolean retval = false;
switch (key) {}
case Characters.ESCAPE:
This.Close ();
break;
by default:
retval = super.keyChar (key, status, time);
}
Return retval;
}
       
private void updateContact() {}
email = c.getString (BlackBerryContact.EMAIL, 0);
System.out.println (email);
If (photo.getChecked ()) {}
make the photo because it is checked
           
}
This.Close ();
}
}
}

Tags: BlackBerry Developers

Similar Questions

  • Problem scrolling in PopupScreen

    Hello

    I added a PopupScreen to my application that will display a given text. When the text is displayed, scroll arrow appears indicating that there is more text to be displayed, however it doesn't let me scroll when I click on the down (tests on a BlackBerry with a trackball).

    The text is displayed in a LabelField (which I believe is not Focusable by default), but even when I say new LabelField ("text", Field.FOCUSABLE), it still doesn't let me scroll down. I tried to add other areas (for example, EditFields) and it seems to work. So I think the problem is with the update?

    Can someone tell me why this is? Here is my code:

    package com.kflicks.ui.Screens;
    
    import java.util.Vector;
    
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    
    public class SynopsisScreen extends PopupScreen implements KeyListener {
    
        Vector results;
    
        LabelField label;
    
        public SynopsisScreen(String synopsis) {
            super(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR),
                    Field.FOCUSABLE);
    
            label = new LabelField(synopsis);
            add(label);
        }
    
        public void close() {
            UiApplication.getUiApplication().popScreen(this);
        }
    
        // ///////////////////////////////////
        // / implementation of Keylistener
        // ///////////////////////////////////
        public boolean keyChar(char key, int status, int time) {
            // intercept the ESC key - exit the app on its receipt
            boolean retval = false;
            switch (key) {
            case Characters.ENTER:
                break;
            case Characters.ESCAPE:
                close();
                break;
            default:
                retval = super.keyChar(key, status, time);
            }
            return retval;
        }
    
        /** Implementation of KeyListener.keyDown */
        public boolean keyDown(int keycode, int time) {
            return false;
        }
    
        /** Implementation of KeyListener.keyRepeat */
        public boolean keyRepeat(int keycode, int time) {
            return false;
        }
    
        /** Implementation of KeyListener.keyStatus */
        public boolean keyStatus(int keycode, int time) {
            return false;
        }
    
        /** Implementation of KeyListener.keyUp */
        public boolean keyUp(int keycode, int time) {
            return false;
        }
    }
    

    Try to exchange your LabelField to a RichTextField and see if that solves your problem.

  • Update of the main screen to a background thread

    Hi guys im trying to update the main screen from a background thread. in this case I'm using a 2 static pictures. Once I click on a butotn on the popupScreen when the application is loaded, it will update the image on the main screen.

    I wrote a small excerpt for it and can you please give me some help with this. because when I've debugged and one of the developers helped me thereby to discover that the screen im trying to update is not the active screen.  Please have alook please.ive extract have 3 classes here

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    SerializableAttribute public class MyApp extends UiApplication
    {

    Public Shared Sub main (String [] args)
    {
    Create a new instance of the application and make the currently
    who runs the thread of the application of the event dispatch thread.
    MyApp PAP = new MyApp();
    theApp.enterEventDispatcher ();
    }
        
    /**
    * Creates a new object MyApp
    */
    public MyApp()
    {
    Push a screen onto the stack in the user interface for rendering.
    pushScreen (new MyScreen());
    final Pinpopup pp = new Pinpopup();

    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    UiApplication.getUiApplication () .pushModalScreen (pp);
    }
    });
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////

    / public final class screen extends MyScreen
    {
    /**
    * Creates a new object of MyScreen
    */
    public Bitmap bmp image;
    public BitmapField bmpField;
    public ButtonField btnDisplay;
    public ImageThread imgThread;
            
    public MyScreen()
    {
            
    Set the displayed title of the screen
    setTitle ("MyTitle");
    BMP = Bitmap.getBitmapResource ("image.png");
    btnDisplay = new ButtonField ("Display");
    bmpField = new BitmapField (bmp);

    btnDisplay.setChangeListener (new FieldChangeListener() {}
                
    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
                    
    if(Field == btnDisplay)
    {
    BMP = Bitmap.getBitmapResource ("image1.png");
    bmpField.setBitmap (bmp);
    signInButtonClicked ("07760926037", "1234");
    LaunchImageThread();
                        
    }
    }
    });
            
    Add (bmpField);
    Add (btnDisplay);
            
    }
        
        
    Public Sub LaunchImageThread()
    {
    imgThread = new ImageThread (this);
    System.out.println ("THIS screen:" + this.getScreen ()); I realized that the im screen update is not active but its strange I don't create any other refrence so
    New Thread (imgThread) m:System.NET.HttpListener.start ();
    }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// POPUPSCREEN CLASS
    class Pinpopup extends PopupScreen //implements FieldChangeListener
    {
    private ButtonField btnOk;
        
    Pinpopup()
    {
            
    Super (new HorizontalFieldManager());

    btnOk = new ButtonField ("Sign In");

    btnOk.setChangeListener (new FieldChangeListener() {}

    ' Public Sub fieldChanged (field field, int context)
    {
    TODO self-generating method stub
    Try
    {
    if(Field == btnOK)
    {
    Close();
    MyScreen ms = new MyScreen();
    Mrs. LaunchImageThread();
    }
    } catch (IllegalArgumentException e) {}
    TODO: handle exception
    System.out.println ("Exception Popup all in signingIn" + e.getMessage ());
    }
    }
    });
            
    Manager fieldManagerContext = new Manager (USE_ALL_WIDTH)
    {
    ' public void sublayout (int width, int height) {}

    int xPos = 10;
    int ypos = 40;

    Field = getField (0);
    layoutChild (field, 280, 50);
    setPositionChild (field, xpos ypos + 100 + 165);

    setPosition (300, 300);
    setExtent (350, 225);
    }
    };
            
    fieldManagerContext.add (btnOk);
    Add (fieldManagerContext);
    }
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////

    / public class ImageThread implements Runnable
    {
    private MyScreen parent;
        
    public ImageThread (MyScreen myScreen)
    {
    parent = myScreen;
    }

    public void run()
    {
    Try
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
                    
    public void run() {}
    TODO self-generating method stub
    System.out.println ("active screen:" + UiApplication.getUiApplication () .getActiveScreen ());
    System.out.println ("active screen:" + parent.getScreen ());
    parent.bmp = Bitmap.getBitmapResource ("image1.png");
    parent.bmpField.setBitmap (parent.bmp);
                        
    }
    });
    }
    catch (Exception ex)
    {
    System.out.println ("Exception in Thread:" + ex.getMessage ());
    }
    }
    }

    was soon thanks

    I suspect that this is your problem:

    MyScreen ms = new MyScreen();
    Mrs. LaunchImageThread();

    I suspect that if you did as I suggested on the other Thread and put a breakpoint in the constructor of MyScreen, you'd have foiund, this creates a second instance.

    I hope that you can take it from here.

  • PopupScreen of application on JDE 4.5

    I would like to develop for JDE 4.5.

    When a user clicks a button in my application, the application makes an HTTP connection and it may take a while.  I would like to show you a GIF file I already created, however, I won't completely push a new screen to the display, but just a small popup image stack.  I know it can be done with the class PopupScreen for JDE 4.6 or higher, but I wonder how it can be done on JDE 4.5?

    Why don't you use PopupScreen on 4.5? This class is available on all JDE versions I know.

  • Problem with PopupScreen.updateLayout)

    Hello guys '

    I have a problem with PopupScreen. I'm doing the cursor on the PopupScreen. This popupScreen includes BitmapField with transparent image. And the main screen is BitmapField larger than the size of the screen. I want to move the cursor (PopupScreen) on the BitmapField.

    You see what I'm doing here. And I found the solution how to move PopupScreen since the last post. Now, I am facing the problem when the cursor (PopupScreen) on the left. In other words, when I move the slider to the left, it is not clear previous position. I don't know why.

    It works fine when moves right.

    And it is not clear the previous, when position moves to the left.

    So, you can see the code that I use.

    import net.rim.device.api.ui.component.*;import net.rim.device.api.ui.container.*;import net.rim.device.api.ui.*;import net.rim.device.api.system.Bitmap;import net.rim.device.api.system.KeyListener;
    
    public class CursorField extends UiApplication {
    
      private InfoPopupScreen progressPopup;    int x = 180;  int y = 120;  ManagedScreen managedScreen;  Bitmap _bitmap1;  Bitmap _bitmap2;  Bitmap _bitmap;   int [] fillTrans = new int[100];
    
      public CursorField() {
    
          _bitmap = Bitmap.getBitmapResource("cursor1.png");        _bitmap1 = Bitmap.getBitmapResource("cursor1.png");       _bitmap2 = Bitmap.getBitmapResource("cursor2.png");
    
          for(int i = 0; i < 100; i++) {         fillTrans[i] = 0xFFFFFF;      }
    
          managedScreen = new ManagedScreen();      pushScreen(managedScreen);    }
    
      private class InfoPopupScreen extends PopupScreen implements KeyListener {
    
          protected void applyTheme() {         //Nothing     }
    
          public boolean keyStatus(int keycode, int time) {         return false;     }
    
          public boolean keyRepeat(int keycode, int time) {         return false;     }
    
          public boolean keyUp(int keycode, int time) {         return false;     }
    
          public InfoPopupScreen(Manager manager){          super(manager);       }
    
          protected boolean navigationMovement(int dx, int dy, int status, int time) {
    
              return true;      }
    
          protected void paintBackground(Graphics graphics) {           graphics.setBackgroundColor(16777215);        }
    
          public void sublayout(int width, int height){         super.sublayout(width, height);           setPosition(x, y);        }
    
          public boolean keyDown(int keycode, int time) {
    
              char key =  net.rim.device.api.ui.KeypadUtil.getKeyChar(keycode, net.rim.device.api.ui.KeypadUtil.MODE_UI_CURRENT_LOCALE);            //To left         if(key == 79 || key == 111) {             x = x - 5;                progressPopup.updateLayout();         }                      if(key == 73 || key == 105) {             x = x + 10;               progressPopup.updateLayout();         }
    
              if(key == net.rim.device.api.system.Characters.ESCAPE) {              this.close();         }         return true;      }
    
          public boolean keyChar(char key, int status, int time) {          return false;     }
    
          public boolean trackwheelRoll(int amount, int status, int time) {         return false;     }
    
          public boolean trackwheelUnclick( int status, int time ) {            return false;     }
    
          public boolean trackwheelClick( int status, int time ) {          super.trackwheelClick(status, time);          return true;      } }
    
      private class ManagedScreen extends MainScreen {      private BitmapField _cursorField;
    
          public ManagedScreen() {
    
              _cursorField = new BitmapField(_bitmap) {             public void paint(Graphics graphics) {                    graphics.setBackgroundColor(16777215);                    super.paint(graphics);                }         };
    
              FlowFieldManager manager = new FlowFieldManager(FlowFieldManager.USE_ALL_HEIGHT | FlowFieldManager.USE_ALL_WIDTH) {               public void paint(Graphics graphics) {                    graphics.setBackgroundColor(16777215);                    super.paint(graphics);                }         };
    
              manager.add(_cursorField);            progressPopup = new InfoPopupScreen(manager);
    
              Bitmap pic = Bitmap.getBitmapResource("background.jpg");          BitmapField picField = new BitmapField(pic);          add(picField);
    
              ButtonField _closeButton = new ButtonField("Push screen", ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER);         _closeButton.setChangeListener(new FieldChangeListener() {                public void fieldChanged(Field field, int context) {                  pushScreen(progressPopup);                }         });
    
              add(_closeButton);        } }
    
      public static void main(String[] args) {      CursorField application = new CursorField();      application.enterEventDispatcher();   }}
    

    I hope you can solve my problem.

    TNX in advance"

    Ttry this...   In paintBackground(), call clear after you set the background color.

  • How to remove the global popupscreen?

    Hello everyone,

    I create the application such that when the application starts at the beginning so I put this request

    in the background and then I push the global popupscreen for help

    UiApplication.getUiApplication () .pushGlobalScreen (currentpopupScreen, 1, UiApplication.GLOBAL_MODAL);

    afterwords when I want to delete this global else popupscreen class, I used the following line of code

    UiApplication.getUiApplication () .popScreen (UiApplication.getUiApplication () .getActiveScreen ());

    but this gives the exception because UiApplication.getUiApplication () .getActiveScreen () returns null.

    So how to remove this global popupscreen? because the other class getActiveScreen () method returns null.

    Thanks in advance

    If I push two (or more) screens with the same priority, newest pushed overall appears on top. I tested.

    Thank you for your suggestion.

  • UiApplication using PopupScreen

    Hi all

    This is my first post on this amazing forum. I read through many large threads with lots of answers to the questions I had in my short time developing applications for the BlackBerry smartphone. Unfortunately, I hit my first stumbling block, which I'm sure will be very easy, but hey, we all start somewhere.

    The question that I'm doing the experience simply creates a PopupScreen in the mainevent thread and wait for user input before continuing. In my days of Swing I just use an observable model and notify the application of change, but I seem to have trouble with this concept here. I tried to use the pushModalScreen and the pushGlobalScreen of the UiApplication class methods, but both give me a runtime... error pushGlobalScreen called by thread of non-event.

    It seems to me missing something probably just in front of me, but I would appreciate help on this. I just use this example using the 9000 Simulator that is packed with the JDE v4.6

    public static void main(String[] args) {
            MyApp app = new MyApp();
            app.enterEventDispatcher();
        }
    
        MyApp() {
            final PromptTest prompt = new PromptTest();
            invokeLater(new Runnable() {
                public void run() {
                    pushGlobalScreen(prompt,1,UiApplication.GLOBAL_MODAL);
                }
            });
            continueProcess();
        }
    
        public void continueProcess() {
        // do something with input from PopupScreen
        }
    }
    

    Thank you.

    Well, I'm a little bit embarrassed. I have solved my problem. Using just pushScreen, like any other approach and all simply migrate code to deal with in my fieldChangeListener. I don't know what I thought earlier. I'm sorry to have lost someone's time on this one.

  • Invoking the application of a midlet blackberry email client.

    Hi guys, I am trying to invoke the blackberry native E-mail application, trying to do until now I'm able to view email compose screen and the data filled in, but my problem is after he gets invoked from in my application it never get all events, as I can not kick it, the BlackBerry shortcut menu does not appear the menu only one that works is the menu that appears by pressing the keys (trackball).

    All events, including the characters of that type in the body of the message i don't get it.

    Please help me.

    what I have done until now is the following:

     net.rim.device.api.system.Application.getApplication().invokeLater(new Runnable()
                {
                    public void run() {
                        MessageArguments mArgs = new MessageArguments                                          (MessageArguments.ARG_NEW,to,msubject, mbody);
                        Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, mArgs);
    
                    }
                });
    

    with the code above in invokeLater, I even tried without invokeLater but in vain.

    my scenario is a user clicks an option in the menu contextual app Feeback Email application opens and with the preset values user can edit too with his comments.

    Thank you

    JH

    Thanks guys, but now I found the solution for my problem mentioned above.

    the issue was with event management, even if my app was painted with screen e-mail editor events received to my main application screens, so I put control of all handlers on the current active form.

      public boolean checkActiveScreen()
       {
           net.rim.device.api.ui.Screen scr = net.rim.device.api.ui.UiApplication.getUiApplication().getActiveScreen();
           net.rim.device.api.ui.Field f = scr.getFieldWithFocus();
           if(null != f)
           {
               return false;
           }
             if (scr instanceof net.rim.device.api.ui.container.FullScreen)
            {
                return false;
            }
            else if(scr instanceof net.rim.device.api.ui.container.MainScreen)
            {
                return false;
            }
            else if(scr instanceof net.rim.device.api.ui.container.PopupScreen)
            {
                return false;
            }
    
           return true;
       }
    

    If the function above has solved my case.

  • Menu remains visible after you make the selection, and does not show Popupscreen

    Hey. Unable to get a (a gaugefield) on a Popupscreen progress bar to show. It is called from a menu. The user clicks a menu item, and a method is called. The method among other pushes a Popupscreen containing a Gaugefield on display battery-code below. Then, he starts a thread which downloads an image and using join() to wait for it complete (long story). Then, in the thread of events, it appears the Popupscreen.

    The menu does not disappear when you click on it in the Simulator (JDE 4.7, the Bold 9700 sim), but the download happens. Once the download is complete, the menu disappears, the Popupscreen is shown and he tried to pop() Popupscreen, causing an IllegalArgumentException.

    I tried to split the method into two methods, the download happened in the 2nd method, because I read the forum search that the UIEngine don't update the display until the method finishes (it runs in the event thread). But it made no difference...

    How can I get this menu to disappear immediately and the push (popup) to work?

    See you soon!

    Justin.

                            progressbar = new GaugeField("", 0, 100, 50, GaugeField.NO_TEXT);
                            progress = new PopupScreen(new FlowFieldManager()) { protected void OnDisplay() { super.onDisplay(); /*cancelButton.setFocus();*/  }  };
                            globalTiles.pushScreen(progress);
    
                            progress.add(new LabelField("Downloading (rest of) picture ..."));
                            progress.add(progressbar);
                            progress.setFocus();
    
                            if (!threadbg.isAlive()) {
                                       threadbg = new ThreadForBgDownload();
                                       threadbg.start();
                            }
                            else {
                                       // Show the progress bar, mostly complete (it is running and was in the bg). Game will start after last bit done
                            }
    
                            threadbg.join(); // Wait for download thread to complete and 'die'
    
                            globalTiles.popScreen(progress);
    

    Rule #1: all display updates should occur on the thread event or synchronized on the lock of the event.

    Rule #2: the thread of events (or now the lock of the event) should never be blocked by lengthy operations.

    The scenario you sketched out is usually handled like this: menu item run() method don't whatever immediate user interface updates are necessary and starts a worker thread. It does not wait until the thread ends before returning. (If so, updates the user interface include pushing a "Please wait" or progress pop up). The worker, at the same time, begins to do its stuff. When it's time to update the user interface (either because the task is completed or to view progress) the worker thread usually called invokeLater (Runnable) (a method in the Application class) where the executable run() method updates the user interface. If the worker thread must receive user input in his work, he can use invokeAndWait (Runnable), where the executable not all interactions of the user and stores the user entry somewhere so that the worker thread can grab after invokeAndWait() returns.

    Although the synchronization on event lock works perfectly well, it is more common for some reason any to invoke a Runnable, perhaps because the latter clearly encapsulates in a separate object the work to be done on the event thread.

    The above policy is the basis of the excellent Peter Strange example I linked to before.

  • pushGlobalScreen (screen, priority, boolean inputRequired) and the deactivation of the application

    I try to use a snippet of a peter_strange post to create tooltips in my application. In the code snippet, the deprecated method pushGlobalScreen (screen, priority, boolean inputRequired) was used to display the pop up. The question I have is that whenever the application is disabled, the ToolTip stays on the screen covering the screen HomeScreen/Call. The behavior that I'm trying to achieve is the ToolTip to be hidden, with the rest of the application without the persistent effect. I tried to mingle with the priority.

    The code snippet below.

     class TooltipThread extends Thread {
    
            Object _notifyObject = new Object(); // Used to allow user to dismiss this Tooltip
            PopupScreen _tooltip; // Screen we are going to display
            UiApplication _ourApplication; // access to pushGlobalScreen and dismissStatus from our Application
            int _displayTime; // in seconds
    
            public TooltipThread(UiApplication ourApplication, PopupScreen tooltip, int displayTime) {
                _tooltip = tooltip;
                _ourApplication = ourApplication;
                _displayTime = displayTime;
            }
    
            public void run() {
                _ourApplication.pushGlobalScreen(_tooltip, 999, false);
                synchronized(_notifyObject) {
                    try {
                        _notifyObject.wait(_displayTime * 1000);
                    } catch (Exception e) {
                    }
                };
                _ourApplication.dismissStatus(_tooltip);
            }
    
            public void dismiss() {
                // notify the waiting object to stop the Thread waiting
                synchronized(_notifyObject) {
                    _notifyObject.notify();
                }
            }
    
        }
    

    Global screens appear above the other forms in the application (non-global).  So the behavior you see is expected.  To solve it, you need detect when your application has been disabled and moved to the background and pop your bubble screen.

  • Get popupscreen user input and store it in the variable

    Hello world. I have a screen that is pushed to start the application

    pushScreen (new SPScreen());

    In the constructor of the form, I push an extension of popupscreen in the stack to get an int from the user through TextField amount.

    UiApplication.getUiApplication () .pushGlobalScreen (new SplashScreen(), 1, UiEngine.GLOBAL_SHOW_LOWER);

    In the popuupscreen, I store the entry under int amount;

    public void fieldChanged (field field, int context) {}

    name = nameTxt.getText ();

    quantity = Integer.parseInt (amountTxt.getText ());

    Close();

    }

    };

    Now I want int amount; in my screen to shoot the user supplied value and whenever you click on a button Add the amount in total, each time increasing the total amount.

     

    public static int amount;

    total int = 0;

    ...

    amount

    = OptionScreen.amount;

    Total = total + amount;

    No matter how many times you press the Add button it only changes the total amount. For example, if I enter 6 as the quantity and press the button 3 times I want the total 18 years, but the total is still only 6.

    I'm sure there's probably a way to pass a reference to the variable, but I have a similar situation where I have a variable which is accessible by a certain screens and can be changed in multiple screens as well.  I delcare a class called globalVars and put the variable.

    public class globalVars {
    
        public static int total;
    
    }
    

    Do only access you anywhere with globalVars.total.

    Kind regards

    Scott

  • Remove the white screen behind PopupScreen

    I'm trying to find the code that will remove the white screen behind a PopupScreen.  What I'm trying to do, is to display a PopupScreen that appears in front of the home screen. When I create my application, I get my popup, but there is a white background that is blocking everything.

    I have to make the white background transparent?

    I use Application instead of Application, given that my code will not run with just Application

    * NEW FOR BLACKBERRY DEVELOPMENT * bare with me if I'm not concise

    Check out this thread:

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-do-a-terms-and-conditions-popup-and-s...

    E.

  • popupscreen without white screen

    wondering how to make it only to see the popupscreen without white screen on the back?

    I'm using pushScreen (new MypopupScreen());

    When I click the icon on the home screen, I want to show only popupscreen.

    How do I do that?

    This code is used to push a global screen from an Application without user interface:

    Ui.getUiEngine () .pushGlobalScreen (popupScreen, 1, UiEngine.GLOBAL_QUEUE);

  • Call Web Service via a Java Application and analyze the response

    I have currently developed a service web (http://nycews.datajump.com/ATMUtilities.asmx/GetReverseGeoCode?Lat=42.9790550&Lng=-78.7856140) as returnes an address in xml format. I need to know what is the best way to call this connection and parse the XML to display the address to the user in a popupscreen.

    Here is a corrected version...

       public String getAddress() {
            String myString = "My String";
            byte[] postData = myString.getBytes();
            String myAddress = null; // address to return
            HttpConnection httpConnection;
            DataOutputStream os;
            Document doc;
    
            String myURLString = "http://www.google.com;interface=wifi"; // use a connection method here
    
            try {
                httpConnection = (HttpConnection) Connector.open(myURLString);
                httpConnection.setRequestMethod(HttpConnection.POST);
                httpConnection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE, "application / requestJson");
                os = httpConnection.openDataOutputStream();
                os.write(postData);
                int rc = httpConnection.getResponseCode();
    
                if (rc != HttpConnection.HTTP_OK) {
                    return "";
                }
    
                httpConnection.getResponseCode();
    
        // The following code was taken from http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800599/How_To_...
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory. newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                docBuilder.isValidating();
                doc = docBuilder.parse(httpConnection.openDataInputStream());
                doc.getDocumentElement ().normalize ();
                NodeList list=doc.getElementsByTagName("*");
                String _node = new String("");
                Node tempNode = null;
    
          //this "for" loop is used to parse through the
          //XML document and extract all elements and their
          //value, so they can be displayed on the device
    
              for (int i=0;i		   
  • PopupScreen + LocationListener

    I have tried to create a Popup (PopupScreen) that displays "search satellite...". "while I'm waiting for LocationListener to call. Once it is called, I put the location listener to null, and I try to fill the PopupScreen. No matter what I do I can't close. I get an IllegalStateException.

    I looked in the forums, I've seen 100 threads that tell you how to do this, people link to these articles KB, but nothing works. I don't know if I'm just not thinking clearly, but I just can't understand it.

    Basically... I'm trying to do something like:

    screen = new PopupScreen(); pertend this is a message in it

    UiApplication.getUiApplication () .pushScreen (form);

    Critier criteria = new Criteria();

    LocationProvider provider = new LocationProvider.getInstance (criteria);

    provider.setLocationListener (new MyLocationListenerHere (this));

    Then in my MyLocationListenerHere I want to lie...

    MyLocationListener (form) {}

    This.some_holder = screen;

    }

    {public locationUpdated Sub (LocationProvider provider, a place)

    do things for contact information

    UiApplication.getUiApplication () .popScreen (this.some_holder.screen);

    }

    IllegalStateException

    Note: I just write this code now for this post, it gives you a good example of what I'm trying to do. If anyone can help me it would be GREATLY appreciated.

    locationUpdated() runs as a background Thread.  In my view, that it is running in your Application, just to get your pop on your event feed!  Usually, it's pretty easy.  Assuming this works, then that's all you need:

    {public locationUpdated Sub (LocationProvider provider, a place)

    Final anti-pop = this.some_holder.screen;

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

    public void run() {}

    UiApplication.getUiApplication () .popScreen (anti-pop);

    }

    };

    do things for contact information

    }

    This code is written from memory, not tested, but I hope that you can find in her compilation errors.

    Let us know how you go.

Maybe you are looking for