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

Adobe AIR Development

Reply
Contributor
brad51
Posts: 32
Registered: ‎02-02-2011
My Device: Playbook
Accepted Solution

Dialog Box from Background App

hi. how can i display an alert dialog box if my app is in the background? also, i don't want to use a dialog box unless my app is in the background.

thanks.

--------------------------------------
Dirty Kitchen Cooking Timer
http://appworld.blackberry.com/webstore/content/37403
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog Box from Background App

You can listen for events when your app has been activated or deactivate (background), but I would not post an alert if your app is in the background, because that will block the user from the current/active application and they would have no idea that the alert came from another app.  Alerts should really only occur from direct user interaction.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Dialog Box from Background App

This is one of the things "modal" dialogs can do.

 

To make a dialog modal, simply don't pass an argument to show() when you call it.  Normally you should be using alert.show(IowWindow.getAirWindow().group);

 

Note that modal dialogs are extremely "rude" for several reasons.  For one thing, it's unlikely what your app is reporting is so important to the user that they will be happy to be interrupted by it while they're in the middle of another task.  That said, the OS may eventually provide a means of letting them suppress modal dialogs from your app (other than, say, uninstalling it, which is probably what I'd do).

 

Secondly, modal dialogs prevent just about any other interaction with the system while onscreen.  The user has no choice but to respond.  They can't even say "hold on a sec, I'm just busy with this other thing and I'll deal with your request in a moment".

 

There are probably some cases where they are appropriate.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Contributor
brad51
Posts: 32
Registered: ‎02-02-2011
My Device: Playbook

Re: Dialog Box from Background App

i'll use both of those techniques:

 

stage.addEventListener ( Event.ACTIVATE, onActivate ); 
stage.addEventListener ( Event.DEACTIVATE, onDeactivate );

and the modal alerts.

 

my app has a timer set by the user. surely, they want to know the timer has ended.

thanks very much.

 

 

--------------------------------------
Dirty Kitchen Cooking Timer
http://appworld.blackberry.com/webstore/content/37403
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Dialog Box from Background App

 


brad51 wrote:

my app has a timer set by the user. surely, they want to know the timer has ended. 


 

Actually, probably not with a modal dialog.

 

I'd suggest you use some audio, which they can mute or turn off in your app if desired, in combination with the undocumented-and-yet-to-be-released Notifications API.  That's how people will expect and want your app to notify them, at least more so than using a modal dialog.

 

Do what you like, but I really believe if you use the modal dialog for that you'll have a lot of uninstalls.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog Box from Background App

[ Edited ]

Not if I am working in another app and some modal alert from another app steals the focus while I am typing or dragging something.  Best way to piss a user off.  I would display a passive message in the app window and have the option to play some sound on completion.  Once the notification API is available in the SDK, you will be able to alert the user from the flag in the desktop bar along the top.

 

Still my suggestion, so you can do what you want, but put yourself in your user's shoes.  Would you like some background application steal away the focus while you are trying to do some work?  Do you like it when that happens on the desktop computer.  Personally drives me nuts.

Please use plain text.
Contributor
brad51
Posts: 32
Registered: ‎02-02-2011
My Device: Playbook

Re: Dialog Box from Background App

how did i not know about the "undocumented-and-yet-to-be-released Notifications API"!

does indeed sound like a better alternative.

thanks very much.

--------------------------------------
Dirty Kitchen Cooking Timer
http://appworld.blackberry.com/webstore/content/37403
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog Box from Background App

@peter:  Wow, how can 2 people almost say the exact same thing at the exact same time?

 

 

Please use plain text.
Developer
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)

Re: Dialog Box from Background App

@petet & jtegen: When they're harbouring a deep hatred for having their workflow interrupted.

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog Box from Background App

@brad51. You can also make it a preference in how they would like to be notified:

 

Notification Method:

  • None
  • Alert while using application
  • Alert while in another application
  • Play Sound

Could be a series of check boxes.  When in doubt, let the end user decide.

Please use plain text.