Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
roses_r
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone
Accepted Solution

How to display images on the main screen UI from a background thread

Hi

 

Im doing this app where i need to display images on the main screen from a background thread. I was looking for some help but I really couldnt find any.

			final Bitmap bit = bmp;
	        final byte [] jp = jpegBytes;
	        
			UiApplication.getUiApplication().invokeLater(new Runnable() {
				public void run() 
				{                   
					camView.jpegBytes = jp;
					System.out.println(bit);
					camView.bmpStream.setBitmap(bit);
					net.rim.device.api.ui.Screen scr = UiApplication.getUiApplication().getActiveScreen();
					scr.invalidate();
					scr.updateDisplay();
					//camView.bmpStream.
				}
			});

 

Please use plain text.
Developer
ahmadahmad
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: How to display images on the main screen UI from a background thread

hi, remove
net.rim.device.api.ui.Screen scr = UiApplication.getUiApplication().getActiveScreen();
scr.invalidate();
scr.updateDisplay();
and try again
Please use plain text.
New Developer
roses_r
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to display images on the main screen UI from a background thread

Do you want me to remove all 3 lines and try?

Please use plain text.
Developer
ahmadahmad
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: How to display images on the main screen UI from a background thread

yes:smileyhappy:
Please use plain text.
New Developer
roses_r
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to display images on the main screen UI from a background thread

Doesnt work that way...And i read in some forum which siad u need to invalidate for the screen to repaint it...But I dont know ..it doesnt work for me

Please use plain text.
Developer
ahmadahmad
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: How to display images on the main screen UI from a background thread

can you post the class
Please use plain text.
Regular Contributor
Saidarao
Posts: 59
Registered: ‎06-10-2011
My Device: 4.7
My Carrier: BB

Re: How to display images on the main screen UI from a background thread

[ Edited ]

Hii,

Can you try this :
 

 

 

getScreen(getScreen(),Ur RequiredScreen Object);



public static void getScreen(Screen removableScreens, Object MainScreen) {

if (!removableScreens.getClass().getName().equalsIgnoreCase(
MainScreen.getClass().getName())) {

Screen requiredScreen = removableScreens.getScreenBelow();
removableScreens.close();
getScreen(requiredScreen, MainScreen);

}

}


Please use plain text.
New Developer
roses_r
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to display images on the main screen UI from a background thread

What does this method do?

 

I dont really understand what it does Saidarao!!

 

Thanks

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display images on the main screen UI from a background thread

Just to clarify invalidate() is used against Fields and Managers and Screens to refresh the existing display - it does not update the contents displayed.  So you should not need this in your code

 

You do need to tell a Field that you have got a new Bitmap for it.  It appears you do this here:

camView.bmpStream.setBitmap(bit);

We can't confirm that you have correctly update bit as we don't see that code.  Assuming what you are doing is correct, in other words you are supplying a valid updated image, then whether or not

camView.bmpStream.setBitmap(bit);

actually updates the Ui will depend on what that Field does in setBitmap.  However if it is a normal BitmapField and you have not overridden setBitmap, this will automatically update the Field and hence the screen, 

 

This is why one of the previous responders suggested you remove lines of code that should not be needed.

 

However as we don't know what setBitmap actually does, we can't be 100% sure you don't need something else to update the screen. 

 

Which is why the previous poster asked you to post your class.  This is the class that camView is an instance of.  And that is what I recommend you do.

 

I have no idea what the code posted by Saidarao does either.  It doesn't look like it will help. 

 

Please use plain text.
New Developer
roses_r
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to display images on the main screen UI from a background thread

Hi Peter_strange I have posted the code on a different thread. the  code where "bit" is created works fine. just  have a look at this the last code ihave posted and if you could see anything strange on it please. because i find nothing strange and i find it not working as well

 

http://supportforums.blackberry.com/t5/Java-Development/How-to-replace-a-bitmapField-in-the-mainscre...

 

cheers

Please use plain text.