Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling 'Swipe to Exit' functionality of the ICS recent apps list

I am developing an Android app that also includes a Service. The 'Swipe to Exit' functionality of the ICS recent apps list closes the app as expected, but the Service just exits along with it and does not receive an onTaskRemoved() callback to tell it to clean up (or onDestroy() for that matter):

http://developer.android.com/reference/android/app/Service.html#onTaskRemoved(android.content.Intent)

This leaves the notification icon in the status bar and I need to make sure this is removed when the app exits.

I've tried setting android:stopWithTask to false (and true) in Manifest.xml and it seems to make no difference.

    <service 
        android:name="com.test.TestService"
        android:stopWithTask="false" 
    />

Any ideas why the onTaskRemoved() callback is not being received?

like image 529
Megsy Avatar asked Nov 05 '22 00:11

Megsy


1 Answers

When the Service started with startService() and onTaskRemoved() was called when the app removed from recent-apps-list by swipe.

But if the Service started with bindService(), then onTaskRemoved() never gets called. Please check reference here to see if it resolves your problem.

like image 178
Chine Gary Avatar answered Nov 09 '22 08:11

Chine Gary