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

Web and WebWorks Development

Reply
Highlighted
Contributor
Posts: 31
Registered: ‎05-06-2011
My Device: 9300
My Carrier: developer
Accepted Solution

background page stops automatically when app is opened.

I have a Blackberry app that have a background process, and it works fine when you first install an app, but when you subsequently open this app and then close it, its background process stops. I think I'm just missing something small, or doing something wrong. My current thoughts, but can't find any related info so far: * There needs to be something in index.html ( resumeBackground ? )

Developer
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: background page stops automatically when app is opened.

Hi,

Please mention the details that you doing in the background....

Contributor
Posts: 31
Registered: ‎05-06-2011
My Device: 9300
My Carrier: developer

Re: background page stops automatically when app is opened.

Thanks for reply sumit.

 

Actually I have implemented a coverage change listener in background page.

When i install the application, i can see the application running in background and the listener is working. Now when i open the application by clicking on application icon. The listener is not working. Then at closing the application, the application is closed and there is no background process running. Now this process never starts again even after i restart the mobile.

 

I am using 2 devices:- 9800, 9780- in both the devices same scenario is there.

 

Hope to get your reply soon.

Developer
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: background page stops automatically when app is opened.

Hello joygupta,

 

If you want your application to run forever on the background, you should handle the way your app closes through the blackberry.app.event.onExit by requesting your app to go background instead of closing it permanently.

 

Here's a little code for this :

 

blackberry.app.event.onExit(onExitCallback);

function onExitCallback() {
  blackberry.app.requestBackground();
}

 This would cause your application to run in background once the user "exits" your app then calls back the blackberry.app.requestForeground() event once you click on the icon again.

 

Hope this helps. Smiley Wink

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: background page stops automatically when app is opened.

Thanks 

 



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Contributor
Posts: 31
Registered: ‎05-06-2011
My Device: 9300
My Carrier: developer

Re: background page stops automatically when app is opened.

yes, you both are right. I have few more concerns..

 

 

I application is designed to work both in offline and online. during offline the data is stored in persistent storage. Once the mobile comes online, the data will be send to server once the authentication of the user is done. for that I was using background page as a listener. Now when I open the application , the background page is destroyed and listener does't work since only a single html page can run at a time.

 

And if i implement the listener, in foreground pages, threading cannot be done. That means user have to wait untill the data is send top server.

 

Is there any solution to the same.

 

Expecting a reply .

Thanks,

Joygupta

Contributor
Posts: 31
Registered: ‎05-06-2011
My Device: 9300
My Carrier: developer

Re: background page stops automatically when app is opened.

i got one more solution for the same that for threading i can use worker.But In this case, if the user changes the page frequently, javascript will be destroyed and data can't be send.