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

Native Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

SystemToast and predefined timeout (my solution)

I know many of us would like to be able to set the timeout on SystemToast instead of an invisible default timeout.


also it's problematic, if you use a button on your Toast - then timeout is counting down from first user UI activity - and I found some cases where it seems that not all UI activity counts as a count-down-starter ;-)


if clicking on the button will trigger a specific action, then this is not a way to go if the user doesn't want to do the button action.

here's my use-case:


Toast as UNDO: SystemToast has a button labeled "undo" and if user clicks it, last action will be undone.  So far so good, but if the user gets the Toast and then does another action (hitting back or an ActionItem or....) I would like to cancel the SystemToast.


problem: cancel() closes the SystemToast without any signal, which means, my delete-logic doesn't run.


my UNDO usecase is described here.

(Run into this because DeleteAction is automatically mapped with DEL key on Q10 - and per accident a user can tip the wrong key.)


now my solution:

SystemToast gets a

property bool killed: false


and in situations, where I cancel() the SystemToast, I also set deleteToast.killed = true.


now the onKilledChanged() signal was emitted and I can test at my SystemToast if killed == true and do the same logic as on timeout.


this is only the half part of the story:

if deleting a record (only on Q10) I don't execute the delete logic, but a preparedToDelete() logic, where in this case I change the Icon of the row and show() the toast. Toast gets also the recordId as parameter.


so the simplified process is like this:



id: deleteAction

if triggered

   if Q10






function doPrepareDelete(recordId)

    // do some stuff

    deleteToast.recordId = recordId





    id: deleteToast

    property int recordId : -1

    property bool killed : false


        if undoButtonClicked

            // reverse UI changes or so

            recordId = -1

        if timeOut


            recordId = -1


        if (killed && recordId > 0)


            recordId = -1



in all cases where I expect the user doesn't want to Undo (Back Action, other Actions) I execute



deleteToast.killed = true


Now I can rely on the default timeout or force it in special situations



perhaps this gives you an idea


I will put a sample project on github later, not enough time yet, because had so much work preparing my sessions for BlackBerry Live / BBJam next week and to do some customer project work and blogging and ....


If you're at BBJam I recommend JAM56 on InvocationFramework and JAM69 Maps in your apps ;-)


I'm in orlando the whole week send me a tweet to meet @ekkescorner


ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner