BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-26-2007, 10:00 AM   #1
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
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, 09:05 AM   #2
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
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, 04:30 PM   #3
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
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, 10:31 AM   #4
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Default yes

Yes, that's what I need to leave while the application continues to operate background
Offline  
Old 11-29-2007, 10:46 AM   #5
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

Application.requestBackground()

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 11-29-2007, 11:35 AM   #6
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Default Thanks works

Thanks works, but when I go and leave the application terminates operation on background
Offline  
Old 11-29-2007, 04:37 PM   #7
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
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, 08:03 AM   #8
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
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, 08:17 AM   #9
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
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, 08:27 AM   #10
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
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, 09:05 AM   #11
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
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, 10:17 AM   #12
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
Default separate

As I separate and run both, but in the same application?
Offline  
Old 12-03-2007, 11:37 AM   #13
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
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, 03:48 PM   #14
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
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, 09:27 AM   #15
lete
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Posts: 51
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, 10:28 AM   #16
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
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, 01:31 PM   #17
richard.puckett
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Schneider Electric Energy Server EBX510 Server For Energy Management- picture

Schneider Electric Energy Server EBX510 Server For Energy Management-

$4350.00



FANUC Server Driver A06B-6077-H111 picture

FANUC Server Driver A06B-6077-H111

$2158.86



FANUC Server Driver A06B-6117-H211 picture

FANUC Server Driver A06B-6117-H211

$3993.99



SERVER TECHNOLOGY 4870-XLS-44 SENTRY VDC 48VOLT DC REMOTE POWER MANAGER picture

SERVER TECHNOLOGY 4870-XLS-44 SENTRY VDC 48VOLT DC REMOTE POWER MANAGER

$299.99



NEW MOXA NPort 6450 Secure Terminal Server , NPort 6450/US , V1.8.0 picture

NEW MOXA NPort 6450 Secure Terminal Server , NPort 6450/US , V1.8.0

$179.99



Server SE-SS 07020 Server Express Single Drop-In - NEW - COMPLETE - Genuine OEM picture

Server SE-SS 07020 Server Express Single Drop-In - NEW - COMPLETE - Genuine OEM

$180.00







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