[ALOY-778] Confirm Dialogs no opening on device
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-03-12T19:06:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Jamie Buckley |
Assignee | Unknown |
Created | 2013-08-07T21:58:33.000+0000 |
Updated | 2018-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>
Just a heads up, the confirm builtin is going to be deprecated soon in favor of simply using the AlertDialog API.
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:
Resolving as invalid as this appears to be expected platform behavior and a suitable workaround is available.
Closing as invalid. If this is incorrect, please reopen.