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
Regular Contributor
MMC
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified
Accepted Solution

blackberry.system.hasDataCoverage()-using after exiting widget?

My widget is a form that my users will be initiating and filling out when they are offline.

 

I know to use the blackberry.system.hasDataCoverage function to check for network connection and if there isn't one, to save the user's input to localstorage. 

 

I'd like to make the process as seamless as possible for them. If they fill out the form(and the data gets saved to localstorage), and then exit the widget, is there a way to leverage hasDataCoverge when they regain connectivity? 

Please use plain text.
BlackBerry Development Advisor (Retired)
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

Hi MMC,

 

You can use the onCoverageChange event to see if anything changed http://www.blackberry.com/developers/docs/webworks/api/blackberry.system.event.html#.onCoverageChang... 



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)
Please use plain text.
Regular Contributor
MMC
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

Thanks so much. So when I add this to my widget's code, the device will understand to use the function even after the widget has been exited from?

Please use plain text.
BlackBerry Development Advisor (Retired)
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

No, the event needs to be used only to track changes while the app is open. On startup simply check System.hasDataCoverage and if you have coverage update the cache



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)
Please use plain text.
BlackBerry Development Advisor (Retired)
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

No, the event needs to be used only to track changes while the app is open. On startup simply check System.hasDataCoverage and if you have coverage update the cache



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)
Please use plain text.
Regular Contributor
MMC
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

Hi Jeff/all,

     I got the hasDataCoverage to work. Is there any way for it to work when the widget has been minimized/Switched application(NOT exiting the widget)? My issue is that the users of my app will be primarily using it when they are out of network coverage.

 

When they're done filling out the form, there's little reason for them to go back into the app when they reach a place with connectivity(they're logging incidents in non-coverage areas). I saw that hasDataCoverage works when the app is open/on screen(or works when switching back to the app from another application), but it doesn't work when it's minimized. 

 

Is there any 'trick' to this? I've been looking at onCoverageChange(which i'm guessing would have the same result). Now i'm researching 'listeners'.

 

Please let me know if there's something else I can try. Thanks!

Mike

Please use plain text.
Regular Contributor
MMC
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

Can I somehow use blackberry.app.event.onBackground to monitor/take action on coverage changes?
Please use plain text.
BlackBerry Development Advisor (Retired)
ababut
Posts: 46
Registered: ‎07-08-2010
My Device: Superberry
My Carrier: Rogers

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

Would checking hasDataCoverage() on the onBackground/onForeground events and acting appropriately work?
-------------------------------------------------------------------------------------------------
Useful resources, food for the brain:
Web(Works) KB - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/tkb-p/browser_dev%40tkb
Please use plain text.
Regular Contributor
MMC
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

I'm not sure. From what i'm reading, Webwork widgets only have one running thread(as opposed to a Java app?). My current understanding is that if they're in the background, they're not doing anything. I might try to use the requestForeground function to see if it can briefly bring the widget back to the foreground for the data coverage check, and then go back to background. Does that sound about right?

Please use plain text.
Regular Contributor
MMC
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: blackberry.system.hasDataCoverage()-using after exiting widget?

Or would an html5 web worker be appropriate to use in this situation?
Please use plain text.