Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15180] Android: Implement an event "taskremoved" when Service.onTaskRemoved() is called

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-17T23:39:22.000+0000
Affected Version/sRelease 3.1.2
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API, Release 3.2.0
ComponentsAndroid
Labelsmodule_android, qe-testadded
ReporterPing Wang
AssigneePing Wang
Created2013-09-13T22:03:17.000+0000
Updated2014-06-19T12:42:52.000+0000

Description

Swiping app away from the recent apps list will kill any background or empty processes of the application but it won't stop the running services or remove the notifications from the status bar. See the discussion here: http://www.howtogeek.com/169549/what-exactly-happens-when-you-swipe-an-android-app-from-the-recent-apps-list/ http://lifehacker.com/what-happens-when-you-remove-an-app-from-androids-mult-1179868228 In order to get notified when the app is swiped away, we need to implement a new event which is fired from [Service.onTaskRemoved()](http://developer.android.com/reference/android/app/Service.html#onTaskRemoved(android.content.Intent)).

Comments

  1. Ping Wang 2013-09-13

    PR: https://github.com/appcelerator/titanium_mobile/pull/4687 For FR: 1. Run the test case below on 4.0+ devices and should see the log "Hello World! I am a Service. I have this to say: Titanium rocks!". 2. Click the HOME button and then swipe the app away from the recent app list. Should see the log "**************************** taskremoved fired". Test case: ----------------------- app.js -----------------------
       var intent = Titanium.Android.createServiceIntent( { url: 'service.js' } );
       intent.putExtra('message_to_echo', 'Titanium rocks!');
       Ti.Android.startService(intent);
       
    ----------------------- service.js -----------------------
       var service = Titanium.Android.currentService;
       var intent = service.intent;
       var message = intent.getStringExtra("message_to_echo");
       
       service.addEventListener("taskremoved", function(){
       	Ti.API.info("**************************** taskremoved fired");
       });
       
       Titanium.API.info("Hello World!  I am a Service.  I have this to say: " + message);
       
    ----------------------- tiapp.xml -----------------------
       <android xmlns:android="http://schemas.android.com/apk/res/android">
               <services>
                   <service url="service.js"/>
               </services>
       </android>
       
  2. Priya Agarwal 2013-10-22

    Verified the fix with: Appc-Studio: 3.2.0.201310181700 Sdk:3.2.0.v20131021142445 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.0.3 Device:Google Nexus 7(v4.2.1), iPOD Touch1(v7.0) Xcode: 5 Taskremoved() working well on android.

JSON Source