Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Is it possible to programmatically close an alert dialog

I would like to programmatically close an alert dialog. Is it possible?

The problem I'm trying to solve is the following: when the device loses the internet connection, I pop up a 'Connection lost' alert. When the connection is found, I pop up a 'Connection found' alert. I would like to address the rare occurrences when the connection is lost and found before the user has had time to close the 'Connection Lost' dialog.

I tried to just update the title and message of the currently displayed alert, but it didn't refresh.

I haven't found how to close the first dialog programmatically (attempted 'hide' and 'close' although it's not in the API documentation and it didn't work).

Does anyone have other suggestions?
Thanks in advance,

— asked May 28th 2010 by Laure Mouillet
  • alert
  • mobile

3 Answers

  • Why don't you make your own "alert" ?
    You can find easily some photoshop iPhone UI elements to emulate the native alert look.

    — answered May 28th 2010 by Dan Tamas
  • This would be a good feature to add. I'll add it to the list

    — answered May 28th 2010 by Jeff Haynie
    1 Comment
    • Hi Jeff did this 'Programmatically close an alert dialog' ever get added?

      — commented August 17th 2011 by david brewer
  • Try the following to use the native platform's Alert box:

        ohCrud = Ti.UI.createAlertDialog({
            title:'Houston: We have a problem!',
            message:'Unfortunately, things are now foobar.'
        ohCrud.show();        // Show debugRez for 4 seconds, as example
        var handleCrud = setTimeout(function(){
            // Or add more code to investigate the issue, etc
        }, 4000);

    The cool thing is that you could technically put this as a function, calling it on an Event: using the var handleCrud to suss things out.



    — answered August 18th 2011 by Jesse Benedict
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.