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
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300

Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

When trying to register a callback function for my Playbook application, my code fails. This worked well in the 0.9.3 simulator. If I comment out the line below, the rest of my code fires. 

 

 

blackberry.app.event.onBackground(handleBackground);

 

 

_________________________________________
www.jasonmace.com/blackberry
New Contributor
yourpalal
Posts: 6
Registered: ‎03-17-2011
My Device: Playbook

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

[ Edited ]

I'm not sure if there is an official solution/recognition of this problem, but overriding window.onblur, or window.addEventListener("blur") seems to work just as well.

 

EDIT: Sorry, in fact, onblur does not work, event.onBackground was succeeding, as it turned out. Make sure you are building with the newest SDK and testing on the newest VM image as this seems to have fixed this problem for me (now there are other problems..).

Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

With the latest builds of the PlayBook OS and the WebWorks SDK we have confirmed that the onBackground() event is working properly... Stay tuned for an update on when the new SDK and simulators will be available.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

Thanks for the input guys. I've uninstalled and reinstalled the latest SDK and sim... no luck.

 

Threw a try catch around the onBackground call...see the image below. I checked the Playbook webworks packager directory and the js file for application events looked to be intact. It had the code for the onBackground method etc... No clues what the issue might be, but if you guys aren't having trouble something must be going haywire with my install.

 

 

onBackgroundError.jpg

_________________________________________
www.jasonmace.com/blackberry
Retired
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

HI Jason,

 

I believe it is a bug in the simulator where it is not raising the onbackground event.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
yourpalal
Posts: 6
Registered: ‎03-17-2011
My Device: Playbook

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

tneil: I don't believe this is an issue with the event not being raised, but rather blackberry.app.event is probably undefined. From what I can see from the alert, the exception message is 'blackberry.app [undefined] is not an object', I was having this issue a while ago (with this exception, as well).

Jason: Try wrapping the call to onBackground like this:

if (blackberry.app && blackberry.app.event){
    try {
        blackberry.app.event.onBackground(myHandler);
    } catch (e) {
         alert("onBackground failed");
    }
} else {
    alert("no event support");
}

This way, you will be able to better pinpoint the issue. I think this problem dissapeared for me when I upgraded to 0.9.4, but you should also make sure that your config.xml specifies blackberry.app.event, with the correct version (1.0.0).

Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

Al, 

 

I end up getting the "No event support". 

 

My config file does have all the right entries. I checked that when I first started having the issue.

_________________________________________
www.jasonmace.com/blackberry
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

[ Edited ]

It seems like none of my blackberry functions are working...

 

I've trapped my call for a standard dialog and it fails as well with a similar message about blackberry.ui

 

 

try {
   blackberry.ui.dialog.standardAsk("Are you sure you would like to exit?", blackberry.ui.dialog.D_YES_NO, dialogCallBack, {title : "Exit Noteworthy", size: blackberry.ui.dialog.SIZE_SMALL, position : blackberry.ui.dialog.LOC_CENTER});
}
catch (err) {
   alert('error: ' + err);
}

 

Here is the error message

 

 

StandardDialogError.jpg

 

 

Just to add.. my config.xml

 

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0" rim:header="RIM-Widget:rim/widget">
  <name>Noteworthy</name>
  <description>...</description>
  <rim:loadingScreen 
	backgroundColor="#000000" 
	onFirstLaunch="true" 
	foregroundImage="NoteworthyLoadingScreen.png" 
	onLocalPageLoad="false">
	<rim:transitionEffect type="fadeIn" direction="left" />
  </rim:loadingScreen>
  <author rim:copyright="2011">J. Mace</author>
  <access subdomains="true" uri="local:///"/>
  <icon rim:hover='false' src='icon.png' />
  <feature id="blackberry.app" version="1.0.0"/> 
  <feature id="blackberry.app.event" version="1.0.0"/>
  <feature id="blackberry.ui.dialog" version="1.0.0"/> 
  <content src="index.htm"/>
</widget>

 

 

 

_________________________________________
www.jasonmace.com/blackberry
New Contributor
yourpalal
Posts: 6
Registered: ‎03-17-2011
My Device: Playbook

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

Hmm.. the only relevant thing that seems different from your config.xml to mine is that I added required="true" for the blackberry.app and blackberry.app.event feature elements. I don't know how much that property is respected, and frankly, I don't remember where I saw that (somewhere on blackberry.com :smileytongue:). Hope that helps!

Contributor
hakanson
Posts: 36
Registered: ‎04-06-2010
My Device: Bold 9700

Re: Playbook 0.9.4 upgrade causes blackberry.app.event.onBackground() to fail.

I'm also having trouble wil calls to standardAsk that have callback.  My standardAsk without a callback works fine, until I use one without and then is broken.

 

I guess I have to go back to good old alert() and window.confirm() until this is fixed.