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
Regular Contributor
divya
Posts: 77
Registered: ‎02-17-2010
My Device: Not Specified

Run thread after application exit

Hi all,

 

I need to run app after exiting the application. but once application exits,my thread is shutting down.. plz help to do this..

 

Actuall requiremnt is while exiting i need to save all images in database.. there might be 50 to 100 images.i have written code to save in database in onClose.. so when user presses back it takes time to save images and then exits the app.. user feels like back press is hanging...

 

public boolean onClose() {
		
		MyDatabase.getInstance().Close();

		System.out.println("**************************** started thread ");
		if (GlobalData.htChannelLogos.size() > 0) {
			MyDatabase.getInstance().InsertToImageTable(
					GlobalData.htChannelLogos);
		}
		System.out.println("**************************** closed thead ");
		System.exit(0);

		return super.onClose();
	}

 

Help me how can i save images in background..

 

 

 

 

Please use plain text.
Developer
alishaik786
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Run thread after application exit

Use this:

 

public boolean onClose() 
{		
	UiApplication.getUiApplication().requestBackground();
	return true;
}

 ====================================================================================

Feel free to click THUMB symbol if answer is correct.

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Please use plain text.
Developer
simon_hain
Posts: 15,863
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Run thread after application exit

putting the application into the background and running the thread is the correct approach.
just note that a thread executes aynchronally, your code above will call system.exit immediately.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
ankit
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: Run thread after application exit

But in that case application will keep running in background. In addition to above you can call the system.exit, once you are done saving the images in the background.
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Please use plain text.