Titanium JIRA Archive
Alloy (ALOY)

[ALOY-778] Confirm Dialogs no opening on device

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2014-03-12T19:06:41.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterJamie Buckley
AssigneeUnknown
Created2013-08-07T21:58:33.000+0000
Updated2018-03-07T22:28:29.000+0000

Description

On an Android device when creating a confirm dialog in Alloy, it will not open when the application is launched, it must instead be put inside of an event listener or will not be triggered, This does not happen on Android Emulator and iOS. Example below demonstrates this problem, comments show the workaround. index.js
var dialogs = require('alloy/dialogs');

	dialogs.confirm({title:'Push Notifications', message:'Register for push notifications?'});		
/*
function doOpen(){
	dialogs.confirm({title:'Push Notifications', message:'Register for push notifications?'});
};
*/
$.win.open();
index.tss
"Window": {
	backgroundColor: "#fff"
}

index.xml
<Alloy>
    <Window id="win" title="Click window to test" backgroundColor="white"
        exitOnClose="true" fullscreen="false"><!-- onClick="doClick" -->
    </Window>
</Alloy>

Comments

  1. Tony Lukasavage 2013-08-07

    Just a heads up, the confirm builtin is going to be deprecated soon in favor of simply using the AlertDialog API.
  2. Tim Poulsen 2014-03-12

    This seems to be simply a case of the alertDialog attempting to open before the window is fully loaded. On Android, alerts are modal to the window that contains them, thus I expect there's no valid window to attach to at the point at which your code runs. Change your controller code to the following and the confirmation dialog is shown as expected:
       var dialogs = require('alloy/dialogs');
       
       _.defer(function() {
           dialogs.confirm({title:'Push Notifications', message:'Register for push notifications?'});
       });
       
       $.win.open();
       
  3. Tim Poulsen 2014-03-12

    Resolving as invalid as this appears to be expected platform behavior and a suitable workaround is available.
  4. Eric Merriman 2018-03-07

    Closing as invalid. If this is incorrect, please reopen.

JSON Source