Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12939] Android: Developer option "do not keep activities" cause Titanium apps to close

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-23T22:46:51.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 15 API, 2013 Sprint 15, Release 3.1.2, Release 3.2.0
ComponentsAndroid
LabelsSupportTeam, android, defect, exalture, qe-closed-3.1.2, qe-port, qe-testadded, triage
ReporterCarter Lathrop
AssigneePing Wang
Created2013-03-01T18:58:27.000+0000
Updated2014-07-11T23:07:41.000+0000

Description

Expected behavior: App remains open and maintains focus after first activity is loaded regardless of Developer Options settings. Current behavior: Activating the "Don't keep activities" option in Developer Options on devices causes Titanium apps to close after the first activity is loaded. This is a major difference between Titanium apps and native Android apps as this option may be checked unbeknownst to the client and thus seen as a bug in the app. Seeing as though users are being instructed to turn this setting on to improve the performance of their devices this becomes a very large problem for those of us developing apps whose success hinges on user confidence.

Comments

  1. John Sanford 2013-03-01

    Unfortunately this issue arose when I was touting the benefits of using Titanium to a coworker and the device loaded all native apps correctly, but when it came time to show the apps from Titanium they all seemed to crash (very embarrassing). It took me a couple of hours to figure out what was going on and to determine as to why my personal devices were all functioning correctly and not the company devices. After figuring out that it had to be a setting in the Developer Options I was able to recreate the issue on my personal devices by turning this option on.
  2. Carter Lathrop 2013-03-02

    John, were you installing the application directly onto the company devices or from the Play Store? If you are manually installing applications, you should turn off developer options after installation so that this option will not be available to an unknowing user. Generally if you are distributing an app, it is not done manually, this is why this is not usually an issue.
  3. Carter Lathrop 2013-03-02

    Also, the "do not keep activities" option does not only stop Titanium apps but some other apps as well (after testing that I did). When I had the "do not keep activities" option on, it was breaking other apps (non-Titanium) as well. This doesn't seem to be a Titanium specific problem rather a result of the options nature.
  4. John Sanford 2013-03-02

    I cannot recreate your scenario. The Java apps created in Eclipse do not lose focus and thus do not get dumped. I have tested this several different ways and it is pretty conclusive that there is some fundamental difference in how Titanium apps handle focused yet inactive activities after the page is loaded. What are some of the non-Titanium programs that have this issue? I've tried many and only the Titanium apps are closing immediately after load.
  5. Carter Lathrop 2013-03-04

    Mainly launcher apps, I didn't run into any problems with the few native apps I tried, so I ventured into a custom launcher and it broke for me. Now that I see that no other native apps are breaking, I see you have a valid point. What would be the ideal behavior here for you? Would you mind adding an Expected behavior vs Actual behavior to your description? Thank you for your patience and bringing this to our attention.
  6. Ping Wang 2013-04-10

  7. John Sanford 2013-04-10

    @Ping Wang your assumption that native apps are affected is incorrect, I urge you to investigate this on your own; create a basic app in Eclipse and then a basic app in Ttanium. The Titanium app will close after initial load and the native app will not. However the pages you have cited address this issue in a way that migt assist the developers in finding a solution to this, especially http://stackoverflow.com/questions/13439300/handle-dont-keep-activities-in-android-app.
  8. Paul Hemetsberger 2013-04-12

    This happened to me upon releasing an update to our app with >500k total installs (a dictionary app quite well-known in the German-speaking world) and caused a flood of complaints, bug reports and negative Play store ratings. It took me two weeks answering e-mails and comments, asking users for log files, buying five additional test devices and testing every setting I could find, until I finally found the correct switch to replicate the problem. And even after posting this in the Play store app description and "recent changes" text field I keep receiving bug reports as other apps don't show this behavior, and our previous version (built on SDK 2.x) didn't, either. Our users definitely see this as a bug. Please fix it!
  9. Ping Wang 2013-05-14

    This issue is blocked by TIMOB-13796 because of the limitation in the current Titanium Android window implementation. Need to refactor the whole window system before solving this ticket.
  10. Banzai Mobile 2013-07-03

    Add my vote for a quick resolution of this long standing SERIOUS issue. Here in Italy things are getting out of control, and we have 900K+ Android downloads of Titanium-based apps. At least one rating out of five is 1-star with comment "crashes on launch" on Samsungs, LG, etc. and ALL are solved by unchecking "Don't keep activities". As Paul wrote, no way to deal with it by posting comments, replies, etc. We are a Google partner, and recently Google told us that they cannot accept that an app warns against a specific phone settings. They cannot block that app, but definitely they won't promote it ANYWHERE in their Play Store.
  11. Ingo Muschenetz 2013-07-03

    [~banzaimobile] Rest assured, we are working on it as we speak.
  12. Ping Wang 2013-07-12

    PR: https://github.com/appcelerator/titanium_mobile/pull/4452 *Note*: 1. When the "Don't keep activities" options is enabled, the lifecycle of the activity is different from the normal situation. Whenever the user leaves an activity which means onStop in the normal case, this activity will be forced to destroy by the Android OS which means onDestroy is called. Later when the user goes back to that activity which means onRestart in the normal case, this activity will be forced to re-create which means onCreate is called. So some events will be fired differently from the normal case. Please use the test case attached below to see when events are fired and how it is different from the normal case:
        Titanium.UI.setBackgroundColor('#000');
          
        // create tab group
        var tabGroup = Titanium.UI.createTabGroup();
          
          
        //
        // create base UI tab and root window
        //
        var win1 = Titanium.UI.createWindow({  
            title:'Tab 1',
            backgroundColor:'#fff'
        });
        var tab1 = Titanium.UI.createTab({  
            icon:'KS_nav_views.png',
            title:'Tab 1',
            window:win1
        });
          
        win1.addEventListener('focus', function(){
            Ti.API.info("win1 focused");
        });
         
        win1.addEventListener('blur', function(){
            Ti.API.info("win1 blur");
        });
        
        win1.addEventListener('open', function(){
            Ti.API.info("win1 open");
        });
         
        win1.addEventListener('close', function(){
            Ti.API.info("win1 close");
        });
          
          
        var button = Ti.UI.createButton({
            title:'open win3',
            width:200,
            height:100
        });
        button.addEventListener('click', function(){
            var win3 = Ti.UI.createWindow({
                title:'foobar',
                backgroundColor:'blue',
                fullscreen:false
            });
            var button2 = Ti.UI.createButton({
                title:'back to win1',
                top: 100,
                width:200,
                height:100,
                backgroundColor:'white'
            });
             
            var button5 = Ti.UI.createButton({
                title:'open win5',
                width:200,
                height:100,
                backgroundColor:'white'
            });
            button5.addEventListener('click', function() {
                var win5 = Ti.UI.createWindow({
                title:'foobar',
                backgroundColor:'green',
                fullscreen:false
                });
                var button6 = Ti.UI.createButton({
                    title:'back to win3',
                    width:200,
                    height:100,
                    backgroundColor:'white'
                });
                button6.addEventListener('click', function(){
                    win5.close()
                });
                win5.add(button6);
                 win5.addEventListener('blur', function() {
                    Ti.API.info("win5 blurred");
                });
                win5.addEventListener('focus', function() {
                    Ti.API.info("win5 focus");
                });
                win5.addEventListener('open', function() {
                    Ti.API.info("win5 open");
                });
                win5.addEventListener('close', function() {
                    Ti.API.info("win5 close");
                });
                win5.open();
             
            });
            button2.addEventListener('click', function(){
                win3.close()
            });
            win3.add(button2);
            win3.addEventListener('blur', function() {
                Ti.API.info("win3 blurred");
            });
            win3.addEventListener('focus', function() {
                Ti.API.info("win3 focus");
            });
            win3.addEventListener('open', function() {
                Ti.API.info("win3 open");
            });
            win3.addEventListener('close', function() {
                Ti.API.info("win3 close");
            });
            win3.add(button5);
            win3.open();
        });
          
        win1.add(button);
          
          
        var win2 = Titanium.UI.createWindow({  
            title:'Tab 2',
            backgroundColor:'#fff'
        });
        var tab2 = Titanium.UI.createTab({  
            icon:'KS_nav_ui.png',
            title:'Tab 2',
            window:win2
        });
         
        win2.addEventListener('focus', function(){
            Ti.API.info("win2 focused");
        });
         
        win2.addEventListener('blur', function(){
            Ti.API.info("win2 blur");
        });
        
        win2.addEventListener('open', function(){
            Ti.API.info("win2 open");
        });
         
        win2.addEventListener('close', function(){
            Ti.API.info("win2 close");
        });
          
        var button10 = Ti.UI.createButton({
            title:'open win4',
            width:200,
            height:100
        });
        button10.addEventListener('click', function(){
            var win4 = Ti.UI.createWindow({
                title:'foobar',
                backgroundColor:'red',
                fullscreen:false
            });
            var button12 = Ti.UI.createButton({
                title:'back to win2',
                width:200,
                height:100,
                backgroundColor:'white'
            });
            button12.addEventListener('click', function(){
                win4.close()
            });
            win4.add(button12);
            win4.addEventListener('blur', function() {
                Ti.API.info("win4 blurred");
            });
            win4.addEventListener('focus', function() {
                Ti.API.info("win4 focus");
            });
            win4.addEventListener('open', function() {
                Ti.API.info("win4 open");
            });
            win4.addEventListener('close', function() {
                Ti.API.info("win4 close");
            });
          
            win4.open();
        });
         
          
        win2.add(button10);
        
        
        tabGroup.addTab(tab1);  
        tabGroup.addTab(tab2); 
        
        tabGroup.addEventListener('open', function() {
            Ti.API.info("tabGroup open");
        });
        tabGroup.addEventListener('close', function() {
            Ti.API.info("tabGroup close");
        });
          
        tabGroup.open();
        
    2. For the same reason described above, the root window of the app has to set *"exitOnClose: true"* when this option is enabled. Otherwise, the app will be not able to back out. For FR: 1. Run KS and Anvil on 2.3.x, 3.x and 4.x devices *without* the "Don't keep activities" option enabled. Should be no new regressions. (Anvil test should have 370 passed / 36 failed). 2. Run Anvil on 4.x device *with* the "Don't keep activities" option enabled. Should be no new regressions. 3. Run KS on 4.x device *with* the "Don't keep activities" option enabled. All the tests should work fine except Base UI->Views->Email Dialog and Phone->Photo Gallery/Camera. For those three tests, since it opens another activity in the window "open" event listener, the test will not be able to back out. Please also put the KS to background (by HOME button) and then select it from the app page or from the history list. Should show the same window from where we left. 4. Follow the test steps in TIMOB-9258.
  13. Ping Wang 2013-07-23

    PR to update doc: https://github.com/appcelerator/titanium_mobile/pull/4475
  14. Benjamin Hatfield 2013-07-23

    Reviewed Doc PR
  15. Ping Wang 2013-07-23

    backport PR: https://github.com/appcelerator/titanium_mobile/pull/4476
  16. Darren Haligas 2013-07-29

    Wow this has been causing me and my client major grief over the last year. This needs to get moved up to 3.1.2
  17. Darren Haligas 2013-07-29

    Thanks for moving this to 3.1.2. Anyword on release date?
  18. Darren Haligas 2013-07-29

    Will this show up in the 3.1.2 nightly builds today?
  19. Ingo Muschenetz 2013-07-29

    [~dhaligas] It should already be in the nightly builds for 3.1.X. [~pwang] Anything special he needs to do to take advantage of it?
  20. Ping Wang 2013-07-29

  21. Darren Haligas 2013-07-29

    Understood. Our client's app won't run when this is enabled currently. They have over 100k installs so getting users in is very important. When will this be GA? On a side note testing this build I have lost my itemclick event in my ListView. Any changes there?
  22. Ingo Muschenetz 2013-07-29

    [~dhaligas] GA for 3.1.2 is mid-August.
  23. Olga Romero 2013-08-15

    Tested KS *with* and *without* the "Don't keep activities" option enabled with: Titanium Studio, build: 3.1.2.201308091617 Titanium SDK, build: 3.1.2.v20130814124556 Alloy: 1.2.0-beta CLI: 3.1.2-alpha Device: GalaxyS4 Android version 4.2.2 Verified behavior, described in comment - 12/Jul/13 12:56 PM

JSON Source