Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27256] Android: AlertDialog cannot be re-shown in a different window as of 8.0.1

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2019-08-21T13:28:34.000+0000
Affected Version/sRelease 8.0.1
Fix Version/sRelease 8.1.1
ComponentsAndroid
Labelsalert, android, dialog, engSchedule, regression
Reporterardy wongso
AssigneeYordan Banev
Created2019-06-20T01:29:00.000+0000
Updated2019-08-21T13:28:34.000+0000

Description

It is working fine in 8.0.0 but not in 8.0.1 in 8.0.1 it return "Dialog activity is destroyed, unable to show dialog with message: null" so here the case 1. i have 1 component of alert dialog with android view which used in multiple page of screen 2. when i show the alert dialog in first screen it works fine 3. when i show the same alert dialog in second screen, the alertdialog not showing, but instead it's on the first screen (when i close the second page, i saw the alert dialog in 1st page) 4. in first page when i try to show the same alertdialog, it return error "Dialog activity is destroyed, unable to show dialog with message: null" Workaround for this issue 1. Keep re-creating new alertdialog unlike previous approach which using 1 alertdialog and used in multiple places.

Comments

  1. Jebun Naher 2019-06-25

    Hi ! Thanks for reporting the issue. Can you please try using latest ti sdk 8.0.2.GA and check if you experience the same? You can download the sdk using this command: *appc ti sdk install 8.0.2.GA* Let us know the update.
  2. Joshua Quick 2019-06-28

    I can reproduce this issue in Titanium 8.0.1 and above with the following code...
       var dialog = Ti.UI.createAlertDialog({
       	title: "Alert Dialog",
       	message: "This is the alert message.",
       	buttonNames: ["OK", "Cancel"],
       	cancel: 1,
       });
       
       var window = Ti.UI.createWindow();
       var button = Ti.UI.createButton({ title: "Show Alert" });
       button.addEventListener("click", function(e) {
       	var childWindow = Ti.UI.createWindow({ title: "Child Window" });
       	childWindow.addEventListener("open", function() {
       		function dialogEventHandler() {
       			dialog.removeEventListener("click", dialogEventHandler);
       			dialog.removeEventListener("cancel", dialogEventHandler);
       			childWindow.close();
       		}
       		dialog.addEventListener("click", dialogEventHandler);
       		dialog.addEventListener("cancel", dialogEventHandler);
       		dialog.show();
       	});
       	childWindow.open();
       });
       window.add(button);
       window.open();
       
    This is likely due to the changes we've made to [TIMOB-26978], where there were known rare crashes with AlertDialog and ProgressIndicator dialog when showing/hiding them from a destroyed activity window. Especially if Android's "Don't keep activities" developer option was turned on. A native Android dialog is designed to be attached to a single activity window and it can internally throw a Java exception on Google's end when showing/hiding it from a destroyed activity. We'll re-look into this. On iOS, a dialog is always shown on top of the app and is not bound to any window. I think we need to look into better replicating this behavior on Android without the above mentioned exceptions that can happen. In the meantime, I recommend that you re-create the alert dialog like you're doing now. _(Natively, I think that's our only option as well to get the same effect.)_ Thanks for bringing this issue to our attention.
  3. Yordan Banev 2019-07-23

    PR: https://github.com/appcelerator/titanium_mobile/pull/11073
  4. Satyam Sekhri 2019-07-30

    FR Passed. Waiting for 8.1.0 GA before merge. Kindly back-port to 8_1_X branch.
  5. Yordan Banev 2019-07-31

    PR (8_1_X): https://github.com/appcelerator/titanium_mobile/pull/11096
  6. Yordan Banev 2019-08-19

    PR (8_3_X): https://github.com/appcelerator/titanium_mobile/pull/11156
  7. Christopher Williams 2019-08-20

    Merged to master, 8_3_X and 8_1_X
  8. Samir Mohammed 2019-08-21

    *Closing ticket* fix verified in SDK version 8.2.0.v20190820104021, 8.1.1.v20190820143437 and 8.3.0.v20190820103430. Test and other information can be found at: PR (8_3_X): https://github.com/appcelerator/titanium_mobile/pull/11156 PR (8_1_X): https://github.com/appcelerator/titanium_mobile/pull/11096 Master PR: https://github.com/appcelerator/titanium_mobile/pull/11073

JSON Source