BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-26-2007, 09:00 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default BackGround

Please Login to Remove!

Hello, I have an application UiApplication and quieron work with a class BackGround but to leave this to continue to carry out the background

As I do try but always fails to run when I go out of the application??
Offline  
Old 11-28-2007, 08:05 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Anyone can help me?

I need to have an application backgroudn within an IU application, but when you go on applying my background to continue operating.

Anyone have any example?

Thanks
Offline  
Old 11-28-2007, 03:30 PM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

are you saying that you want the application to run in the background when you exit to the background without closing the app?
Offline  
Old 11-29-2007, 09:31 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default yes

Yes, that's what I need to leave while the application continues to operate background
Offline  
Old 11-29-2007, 09:46 AM   #5 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Application.requestBackground()

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 11-29-2007, 10:35 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks works

Thanks works, but when I go and leave the application terminates operation on background
Offline  
Old 11-29-2007, 03:37 PM   #7 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

what's the operation you're seeing terminated? requestBackground does just that, puts it on the back burner but it still should work
Offline  
Old 12-03-2007, 07:03 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default The background makes an http connection

The background makes an http connection and reads records from a database, to have these records updated the icon of the application every 15 minutes. I need the background to continue working even leaving the application and that this always in operation since the turn blackberry.
Offline  
Old 12-03-2007, 07:17 AM   #9 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can change the application icon, using an alternative entry point, from another application which would run as a system service.

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-03-2007, 07:27 AM   #10 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Of course

Of course it did in this way but I need to be done from the same application .. So far work for me but when I go into the application, not to leave still running.
Offline  
Old 12-03-2007, 08:05 AM   #11 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you want to do it in one application all you have to do is seperate the working parts from the ui parts using threads.
RequestBackground changes nothing for your application except that it is no longer visible, if your application terminates it is likely that you have an error in your code.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-03-2007, 09:17 AM   #12 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default separate

As I separate and run both, but in the same application?
Offline  
Old 12-03-2007, 10:37 AM   #13 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Everything that blocks (let the program wait) should be handled in a seperate thread.
Modal Screens, for example, are all handled in their own threads.

if you want a thread to run unlimited times you can work with timer.schedule or while(true) and thread.sleep
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-03-2007, 02:48 PM   #14 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Already separate classes

Already separate classes but I still left to run when I go out of the application
Offline  
Old 12-05-2007, 08:27 AM   #15 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default when I close the screen stops working the background.

I have a class uiapplication and a class of application that makes background. Does the background and when I go to the screens continues to operate the background, but when I close the screen stops working the background.
Offline  
Old 12-05-2007, 09:28 AM   #16 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you misunderstood the concept of threaded execution (i have to guess a bit as your text is quite hard to understand for a non-native speaker).

you need only one application which is of the type UiApplication as it features user interaction.
As soon as an UI element like a screen is pushed your application is visible.
If you call requestBackground() your application switchs to the background. You can access it using the task manager (alt+ESC), for example.

All UI elements are worked by the event thread, an internal thread of the device. By pushing a screen you put it in the queue of the event thread which displays it. The 'enterEventDispatcher' used in the beginning of an UiApplication shows this.

Blocking operations like networking, large calculations or file i/o are seperated from the event thread as their execution would stop the function of the BB UI otherwise. Thus you define sub-classes in your application and run them with certain tasks.

Here is an example. I use the (kind of) dirty direct class reference without interfaces to make things simpler.

Code:
public static void main(String[] args) {
	MyApp theApp = new MyApp();
	theApp.enterEventDispatcher();
}

//constructor
public MyApp(){
//define a Screen and show it
	actionScreen = new ActionScreen(this); 
	pushScreen(actionScreen);
//do many things


//define a background thread
	new BackgroundWorker(this).start();
	requestBackground();
}
if your BackgroundWorker finishes it calls the application using the reference it got in the constructor. The application now requests foreground and can display any information the BackgroundWorker got.

Maybe i should start giving BB workshops instead of developing myself
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-05-2007, 12:31 PM   #17 (permalink)
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

@simon.hain: We need someone to write a book! Look at all the books out there for Symbian, WinMo, even Brew. But not a single decent development book for BlackBerry.

@lete: For these threaded "background" tasks you should check out the Observer pattern. Here's a Wikipedia link so you don't even need to Google it.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.