Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11264] Android: Event "closeFromActivity" cannot be fired on Android

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-11-26T23:26:50.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.0.0, Release 3.1.0, 2012 Sprint 21 API, 2012 Sprint 21
ComponentsAndroid
Labelsapi, module_android, qe-and100112, qe-testadded, regression, tabgroup
ReporterTamila Smolich
AssigneeHieu Pham
Created2012-10-04T23:16:00.000+0000
Updated2013-04-03T22:57:06.000+0000

Description

Description: While testing Android I noticed, that clicking on Android "back" button, which should return user to the red (previous) window, returns to the apps menue. In the console getting a warning:
[WARN][V8Object(  334)] Runtime disposed, cannot fire event 'closeFromActivity'
This is a regression, does not occur on 2.1.3. Steps: 1. Run the following code:
Titanium.UI.setBackgroundColor('#000');

gt = { ui:{} };

gt.ui.createNavigationGroup = function(options) 
{
	var navGroup = 
	{
    	stack: [],
        window: options.window,
        to_root:options.to_root || false
    };

    navGroup.open = function(win, options) 
    {
        Ti.API.info('pre open stack length: ' + navGroup.stack.length);
        
        if (navGroup.stack.length == 0) 
        {
            navGroup.window.addEventListener('android:back', navGroup.go_back);
            Ti.API.info('addEventListener android:back');
        }

        navGroup.stack.push(win);
        win.open(options);
        Ti.API.info('after open stack length: ' + navGroup.stack.length);
    };

    navGroup.close = function(win, options) 
    {
        var idx = navGroup.stack.indexOf(win);
        Ti.API.info('idx: ' + idx);
        if (idx != -1) navGroup.stack.splice(idx, 1);
        win.close(options);
        win = null;
    };

    navGroup.go_back = function(options) 
    {
        var win = navGroup.stack.pop();
        if (win) 
        {
            win.close(options);
            win = null;
        }

        if (navGroup.stack.length == 0) 
        {
            Ti.API.info('removeEventListener android:back');
            navGroup.window.removeEventListener('android:back', navGroup.go_back);
            Ti.API.info('navGroup window close');   
        }

    };

    navGroup.go_home = function() 
    {
        while (navGroup.stack.length) 
        {
            navGroup.go_back();
        }
    };

    return navGroup;

}

var tabGroup = Titanium.UI.createTabGroup();

var navWindow = Ti.UI.createWindow(
{
    backgroundColor:'#ccc',
    navBarHidden:false
});


var tabWindow = Ti.UI.createWindow(
{
    backgroundColor:'#ccc'
});

tabWindow.addEventListener('click', function()
{
    navTab.open(navWindow);
});


var navBtn = Ti.UI.createButton(
{
    title:'open red win',
    color:'#f00',
    width:200,
    height:40
});

navWindow.add(navBtn);


var nav = gt.ui.createNavigationGroup(
{
    window:navWindow
});


navBtn.addEventListener('click', function()
{
    var win = Ti.UI.createWindow(
    {
        backgroundColor:'#fcc'
    });


    var navBtn2 = Ti.UI.createButton(
    {
        title:'open yellow win',
        color:'#ff0',
        width:200,
        height:40
    });


    win.add(navBtn2);

    navBtn2.addEventListener('click', function()
    {
        var win2 = Ti.UI.createWindow(
        {
            backgroundColor:'#ffc'
        });


        var navBtn3 = Ti.UI.createButton(
        {
            title:'close red win',
            color:'#000',
            width:200,
            height:40,
            top:50
        });


        navBtn3.addEventListener('click', function()
        {
            nav.close(win);
        });

        win2.add(navBtn3);


        var navBtn4 = Ti.UI.createButton(
        {
            title:'go home',
            color:'#0f0',
            width:200,
            height:40,
            top:150
        });


        navBtn4.addEventListener('click', function()
        {
            nav.go_home(win);
        });

        win2.add(navBtn4);

        nav.open(win2);
    })


    nav.open(win);
})


var navTab = Ti.UI.createTab(
{
  id: 'navTab',
  title:'navGroup',
  window:navWindow
});

tabGroup.addTab(navTab);

tabGroup.open();
2. Click "open red win" button 3. Click "open yellow" button 4. Press Android "back" button Expected: You should return to the red (previous) window Actual: Returning to the apps menue

Comments

  1. Bill Dawson 2012-10-10

    There's another problem that may or may not be related: In 2.1.3, when you open the red window it opens within the confines of the tab. In 3.0.0 it opens above (larger than) the tab. Investigating. Interestingly, this problem actually brings us _into_ parity with iOS.
  2. Bill Dawson 2012-10-10

    And another problem: In 2.1.3, when you open a tabgroup from app.js, that tabgroup becomes the screen, so to speak. No title is above it. In 3.0.0, you get a title bar above the tab (showing the title of the App.)
  3. Bill Dawson 2012-10-10

    Creating separate tickets for those.
  4. Tamila Smolich 2012-10-10

  5. Bill Dawson 2012-10-10

    This is a tabgroup related ticket. Used git bisect to narrow down to commit a7e5694. Re-assigning to api.
  6. Hieu Pham 2012-10-17

    master PR: https://github.com/appcelerator/titanium_mobile/pull/3237
  7. Tamila Smolich 2012-10-18

    Closing as fixed. Verified and tested on: Titanium Studio, build: 3.0.0.201210151149 Titanium SDK, builds: 3.0.0.v20121018140140; 3.1.0.v20121017102121 Device: Nexus 7 (4.1.1)
  8. Ping Wang 2012-11-21

    3_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/3282
  9. Martin Guillon 2012-12-06

    This pull request created a regression. if you have multiple textfield, using the next button of the soft keyboard, you could automatically focus the next textfield. That pull request broke that feature.

JSON Source