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.

Tags: BlackBerry Developers

Similar Questions

  • Update of the main screen at the click of the button

    Hello world.

    I am very new to BB programming without any programming background at all (I am a philologist). Just try to understand everything now.

    I wrote a test code (in this case OS5) who must do the following - the main screen contains a key, which would add a text on the main screen.

    The code goes here:

    Class MyApp

    package mypackage;
    
    import net.rim.device.api.ui.UiApplication;
    
    public class MyApp extends UiApplication
    {
        public static void main(String[] args)
        {
            MyApp theApp = new MyApp();
            theApp.enterEventDispatcher();
        }
    
        public MyApp() {
            pushScreen(new MyScreen());
        }
    }
    

    Class MyScreen

    package mypackage;
    
    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.ButtonField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen; 
    
    public final class MyScreen extends MainScreen implements FieldChangeListener {
        private ButtonField buttonField;
        private MyScreen myScreen;
    
        public MyScreen() {
            setTitle("Test clock");
            buttonField = new ButtonField("Press me", ButtonField.CONSUME_CLICK);
            add(buttonField);
            buttonField.setChangeListener(this);
        }
    
        public void fieldChanged(Field field, int context) {
            if (field == buttonField) {
                go();
            }
        }
    
        private void go() {
            synchronized(UiApplication.getEventLock()) {
                myScreen.appendLabelText("Update");
            };
        }
    
        public void appendLabelText(String text) {
            LabelField labelField;
            labelField = new LabelField();
            labelField.setText(labelField.getText() + " \r\n" + text);
        }
    }
    

    Could someone make it clear to me how I can get the expected result of what I have?

    Thanks for your help.

    to correct the code above you can:
    -set the LabelField as a class variable
    -Add the LabelField on-screen
    -call setText on this LabelField rather than your method appendLabelText

  • Apple Watch is a day of rest on the main screen

    I noticed this morning that my Apple Watch is one day behind the main screen. The calendar is correct, however. Is there any solution for this?

    Hello

    If you have not already done so, it can help to upgrade your iPhone and Apple Watch to the latest version of the software, from your iPhone:

    Otherwise, the following steps may help:

  • 'Reply' / 'Write' form is hidden behind the main screen of you bird

    Since I updated to the latest version of you bird (v.24.6) last week, I am unable to make the electronic form forward when displaying the main screen of boxes to letters. By clicking on the edge of the screen to answer/write will show it only momentarily, then he is hiding behind the screen of mailboxes. To write a new email, I have to minimize the mailbox main screen.

    I looked for an option that will allow the form of response/writing stay on top, but fails. I made no changes to the options when I updated. I forget a new option somewhere?

    Thanks for any help
    P.S. Win 7 x 64

    Matt,

    You nailed it. Without the Add-ons, it works as it should. Now, I have to determine which of my modules is the culprit. I have day some after I installed the last you bird. I have not that much, so it should be an easy thing to disable all and then putting back one by one.

    Thank you.

  • Problem with the main screen of firefox

    After the update of firefox to firefox 15.0 16.0.2's problem with the main screen. At the top of the main screen displays the bar (caption bar of the main form) that I have win xp and under this title is bar legend like win 7.

    Firefox is running on Windows Xp, if better, I can send the screen, but I don't know where is possible add image to this error report...

    Okay, the problem has been resolved, problem was with the Tab Mix Plus extension. I have an older version of this extension, because at work may not update directly, because I'm going to the Internet via a proxy. Download, update firefox extension directly through the proxy is not possible... I need to download via the other internet browser, in order to not do it often...

  • Windows move to the main screen when sleeping Satellite-S50T-B

    Satellite S50T-B, Windows 8.1. Whenever my laptop sleeps, it moves all the icons and windows open on the secondary external monitor on the laptop monitor. Like a lover double screen, it's extremely annoying. I keep having to set up my work space.

    I expect that there is a bug in the video driver, which means that she sees the monitor off as a result of the command 'sleep' of the laptop as a monitor "unplugged" and it is reported to the operating system for the operating system moves all the icons and windows on the main screen, so when I turn again, they are all in the wrong place.

    Please note that the disappearance of the screen as a direct result of it being sent a sleep command should not be interpreted in any way other than the monitor to sleep as said.

    The graphics driver is old way... When can we expect an update?
    When I can see a fix for this frustrating problem?

    Hello

    If you would google for this problem, you will find a lot of discussions and information about this system.

    From my point of few this issue is linked to the State in sleep mode. There are the States of sleep mode (S0, S1, S2, S3, S4)

    S3 is generally the default standby mode, while the S4 is generally the mode of hibernation by default.
    Here all the details:
    http://msdn.Microsoft.com/en-us/library/Windows/hardware/ff564575

    You can use the PowerCfg command to change these settings
    http://TechNet.Microsoft.com/en-us/library/cc748940%28V=WS.10%29.aspx

  • Update on the fly screen

    Hi all - need some advice if please as does not work how to do this. Have an application built using BB SDK 5, which has several screens, even if you don't need to go beyond the first screen - it contains just tests options. Fact on this first main screen, I have a check box that is bound to a boolean object in a persistent storage.

    This storage of persistent object can be updated through various other screens and a listener SMS accepting incoming SMS messages and running orders based on these messages. However, I find that if I make a change and then say with the BB back button to view my original screen, the value is not translated. As the screen is not jumped to any point of sound as well as the values have been implemented cache or not reread about Summers to update.

    So the question is, is there a way to force a screen to refresh without knowing where it is on the stack, although it will be the first or the last because of how the application works and depnding or not having passed the first screen or not? Also take the scenario of the app displaying the main screen and an SMS comes to tell him to update this persistent storage related to the CheckBox object, the same question applies - is it possible to update the screen if the user only has the screen open on time? Bravo for assistance.

    Have you tried the override of the method onExposed to screen? This would at least give you the opportunity to update the items on the screen each time the new screen focus. Don't know if it would work for when you receive an SMS while on this screen, however.

    You can assign the SMS listener also force an update of the screen if it's in the display battery (isDisplayed).

    http://www.BlackBerry.com/developers/docs/5.0.0api/NET/rim/device/API/UI/container/MainScreen.html

    Hope that helps!

  • On the main screen color questions

    Hello

    So I use the X201T with very bright display on Win7 64.  From time to time display on my screen color seems to be very off, almost as if the gamma have been shifted too far.  All graphics settings seem fine, yet the only solution seems to be a reboot.  Initially, I noticed the problem seems to occur more often when waking from sleep, but this is no longer the case.  Took me to update to the latest version of the bios and video drivers, but always without success.

    Today, I noticed something interesting on the problem.  When I have an external display connected, the colors on the outside are very good if I cloned the original display or extended desktop.  However, what I've learned today, is that when the issue is raised, it is connected permanently to the main screen only - which means that if I have my external screen defined as my main screen, there only color problems while my laptop display looks great.

    I don't know if this could be a hardware problem, a bios problem, a driver problem or a graphic properties issues intel.  Any help would be greatly appreciated .

    Thank you

    Just a quick update incase somebody stumbles on this thread:

    The problem seems to be the lenovo display driver.  Although I tried to install the display driver intel in the past, the only solution was a clean Windows 7, followed by the installation of the driver setup intel only.

    Note that in my first own installation, I opted for the display of lenovo driver and still had persistent problems of color.  On my second try, I went straight for the intel driver and do not know the problem any longer.

  • How to return to the main screen after watching downloads?

    This such a stupid question, but I have forgotten how to return to the main screen after watching downloads.

    Close the window or tab to download (if you are using some addon) or only to change the tab:

    Downloads:

  • My mouse is stuck on the main screen (add pictures)

    I'm used to 2 monitors, and I want to keep it this way. So I implemented a QUANIX monitor I have via HDMI to my Sprout.

    I have extension success of two monitors. but my mouse cursor is stuck in the main screen of Sprout.

    If I drag a window to the next screen, the window can move to the second monitor. but my mouse cursor is stuck on the first monitor.

    How can I solve it?

    Please help me... T_T

    (You can see in detail through below the images)

    monitor 1: HP all-in-one

    Monitor 2: horizontal HP

    Monitor 3: MON-SIS330 (QNIX QX2400)

    Current value of monitors

    captured when dragging a window to the next monitor

    I can find the solution to another post. Sprout Service stop and I can't success using extended display.

  • set the second screen as the main screen

    I have an external monitor connected to my macbook pro. Is it possible to put this external monitor as the main screen. It seems that El Captain only opens new windows and applications on Macbook Pro screen.

    You can change the order via system preferences > display > Arrangement. Drag the white line (menubar) on the second screen to make it primary.

  • How can I access my space girls 14 years old, on the main screen on the computer?

    How can I access my space girls 14 years old, on the main screen on the computer? So I can see what she gets up to the computer because I have no way of knowing.  She went totally bananas when I put parental controls on its site.  It has a password.  I am the administrator of computers.  Thank you

    I assume you have no access to the password for the user of your daughter.  As an administrator, you may open the control panel in Win XP and select user accounts.  The options will allow you to change or remove the password of your daughter.  Then you could sign on behalf of your daughter.
    However, who would probably trigger another outbreak of 'bananas', because your daughter will realize that you have changed or deleted her password.  This forum is not how parents react to problems of girl.  However, she is only 14, is YOUR computer and you have good reason to worry about his online activities.
     
     

    "maidmarion" wrote in message News: d6c42d7e-eb05-43a4-9723-ac451a17b15a...

    How can I access my space girls 14 years old, on the main screen on the computer? So I can see what she gets up to the computer because I have no way of knowing.  She went totally bananas when I put parental controls on its site.  It has a password.  I am the administrator of computers.  Thank you

  • Product key not recognized during a repair of xp pro sp2 on a genuine xp pro sp2 disk. stuck on the main screen of the product.

    After starting problems on my Toshiba satellite with xp pro sp2, I booted my xp pro sp2 disk and did a repair instead of a reinstall software.  He went through the motions, removed the sys files, copied them back and so on.  Then he asked my product key and I typed in it and it does not recognize.  It's a real bought copy of xp pro sp2.  Now, I'm stuck on the main screen of the product.  When I start the laptop on the xp disk it blue screens, the only option I have is to enter a product key in the configuration...  I have my receipt for my xp pro disk and product key for certification sticker.  Help, please!

    "XP MCE Pro? That is not normal! It would be one or the other (AFAIK). Here is an example:

    http://cdn2.ioffer.com/IMG/item/811/353/46/o_XyuQav94U1MQ0Ci.jpg

    If the hybrid you mention is the real thing, it's new to me! I know that some have described as a superset of Pro MCE, but I never used this version, so I can't tell you definitively that a COA sticker wouldn't this combo of terms...

    In addition, the term 'Enterprise Edition' implies something not legitimate. I do not think that Microsoft has never used the term marketing for Windows.

    If you had a legitimate retail version of Windows XP (any version) that is not used on another PC, you can perform a Clean Install (not a repair installation), using this key (not the key COST laptop). The only way you can use the key from your laptop COST would be if you used the correct installation CD - a generic OEM version of the corresponding XP (MCE?) version. In this way, you can perform a clean installation or a repair installation.

    Have you looked at the links I posted? What do you mean by "boot option? The instructions were to press the zero key while turning on the laptop. You are not supposed to enter the OS! The recovery partition is quite distinct.

    If your laptop does not a recovery partition, you should be able to get the correct recovery CD for this Toshiba - by Toshiba or you might need to find a reputable eBay merchant, etc.. Restoredisks.com, who has a good rating from Better Business Bureau, they probably sold too.

  • Help with the screen turned on the main screen

    Hello:

    I wonder how to make a screen shot on the main screen of my files that are on my screen.

    Thank you

    Appleblossom47

    Hello:

    I wonder how to make a screen shot on the main screen of my files that are on my screen.

    Thank you

    Appleblossom47

    Press print screen printscreen-go to 'paint' and then press ctrl and v, then save and send.

    If you do a lot of that there are free progs on the web

  • less red sign on the main screen

    How can I get the Red minus sign off the main screen that appears next to the battery icon?   something with expired subscription?

    Thank you

    Go to Services/Rhapsody/delete subscriptioninfo.xml

Maybe you are looking for