Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7678] Android: OptionDialog does not always not always open

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-08-28T20:32:17.000+0000
Affected Version/sRelease 2.0.0, Release 2.0.2, Release 1.8.1, Release 2.1.2
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api
ReporterSimon R
AssigneeHieu Pham
Created2012-02-07T00:29:31.000+0000
Updated2017-03-22T20:38:02.000+0000

Description

Problem Description

On Android (2.3, but reports of 2.2 also), using SDK 1.8+, OptionDialog behaviour seems to be erratic. There seems to be two separate issues:

Dialogs on our main screen open fine one first load, repeated opening and closing, however once you navigate away from that window, when you return, the dialogs no longer display

App wide events which display dialogs open fine once, but sometimes not subsequently

Some code to replicate issue 1 is below. This bug occurs on both device and emulator. This does not occur with SDK < 1.8

Actual results

option dialog not showing, and you get this in the log: W/TiUIDialog( 386): (main) [2,8442] dialog activity is destroyed, unable to show dialog with message: null

Expected Results

The option dialog showing always

Test case

Open app

Click "Open dialog", dialog opens

Close dialog

Click "Open window", window 2 opens

Go back to window 1

Click "Open dialog", dialog does not open

If dialog opens, repeat steps 3-6 multiple times, dialog will fail within 2-3 repeats

var win1 = Titanium.UI.createWindow({  
    title:'Window 1',
    backgroundColor:'#fff'
});
 
var button1 = Titanium.UI.createButton({
    title: 'Open window',
    top: 30
})
 
var button2 = Titanium.UI.createButton({
    title: 'Open dialog',
    top: 80
})
 
button1.addEventListener('click',function(){
    var win2 = Titanium.UI.createWindow({
        backgroundColor: '#fff',
        modal: true,
        title: 'Window 2'
    })
    win2.open()
});
 
button2.addEventListener('click',function(){
 
    var optionDialog = Titanium.UI.createOptionDialog({
        buttonNames: ['Ok'],
        title: 'Dialog'
    })
    optionDialog.show()
});
 
win1.add(button1);
win1.add(button2);
 
win1.open();

Comments

  1. Simon R 2012-02-07

    I should have added this is related to this Q&A post: [http://developer.appcelerator.com/question/131734/android-23-optiondialog-issues]
  2. amplop keren 2012-07-08

    I had your problem, try not to use local variable when createOptionDialog on android. Try use global variable as you can see on the Kitchen Sink example of Option Dialog
  3. Hieu Pham 2012-08-28

    The fix for timob-7024 fixes this problem. Here's the PR link: https://github.com/appcelerator/titanium_mobile/pull/2324 We will backport this fix to 2.0.X.
  4. Lee Morris 2017-03-22

    Closing ticket as duplicate of the ticket that is mentioned above and has since been closed.

JSON Source