BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links




Reply
 
LinkBack Thread Tools
  (#1 (permalink)) Old
lete Offline
Thumbs Must Hurt
 
Posts: 51
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Default BackGround - 11-26-2007, 10:00 AM

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??
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
lete Offline
Thumbs Must Hurt
 
Posts: 51
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Default Anyone can help me? - 11-28-2007, 09:05 AM

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
   
Reply With Quote
  (#3 (permalink)) Old
bemshaswing Offline
Talking BlackBerry Encyclopedia
 
Posts: 201
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Default 11-28-2007, 04:30 PM

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

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

Application.requestBackground()

hth,
simon


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

Thanks works, but when I go and leave the application terminates operation on background
   
Reply With Quote
  (#7 (permalink)) Old
bemshaswing Offline
Talking BlackBerry Encyclopedia
 
Posts: 201
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Default 11-29-2007, 04:37 PM

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

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.
   
Reply With Quote
  (#9 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 761
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 12-03-2007, 08:17 AM

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
   
Reply With Quote
  (#10 (permalink)) Old
lete Offline
Thumbs Must Hurt
 
Posts: 51
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Default Of course - 12-03-2007, 08:27 AM

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.
   
Reply With Quote
  (#11 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 761
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 12-03-2007, 09:05 AM

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
   
Reply With Quote
  (#12 (permalink)) Old
lete Offline
Thumbs Must Hurt
 
Posts: 51
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Default separate - 12-03-2007, 10:17 AM

As I separate and run both, but in the same application?
   
Reply With Quote
  (#13 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 761
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 12-03-2007, 11:37 AM

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
   
Reply With Quote
  (#14 (permalink)) Old
lete Offline
Thumbs Must Hurt
 
Posts: 51
Join Date: Jun 2007
Model: 8100
PIN: N/A
Carrier: movistar
Default Already separate classes - 12-03-2007, 03:48 PM

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

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.
   
Reply With Quote
  (#16 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 761
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 12-05-2007, 10:28 AM

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
   
Reply With Quote
  (#17 (permalink)) Old
richard.puckett Offline
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Posts: 212
Join Date: Oct 2007
Location: Seattle, WA
Model: 8800
PIN: N/A
Carrier: AT&T
Default 12-05-2007, 01:31 PM

@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.
   
Reply With Quote
Reply


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-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1