Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <service
- android:name="com.myapp.MyService"
- android:stopWithTask="true" />
- <service
- android:name="com.myapp.MyService"
- android:stopWithTask="false" />
- public void onTaskRemoved(Intent rootIntent) {
- //unregister listeners
- //do any other cleanup if required
- //stop service
- stopSelf();
- }
- int previousProcessID = mSharedPreferencesUtils.getInt(SharedPreferencesUtils.APP_PROCESS_ID);
- int currentProcessID = android.os.Process.myPid();
- if ((previousProcessID == currentProcessID)) {
- // This ensures application not killed yet either by clearing recent or anyway
- } else {
- // This ensures application killed either by clearing recent or by anyother means
- }
- public class OnClearFromRecentService extends Service {
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- Log.d("ClearFromRecentService", "Service Started");
- return START_NOT_STICKY;
- }
- @Override
- public void onDestroy() {
- super.onDestroy();
- Log.d("ClearFromRecentService", "Service Destroyed");
- }
- @Override
- public void onTaskRemoved(Intent rootIntent) {
- Log.e("ClearFromRecentService", "END");
- //Code here
- stopSelf();
- }
- <service android:name="com.example.OnClearFromRecentService" android:stopWithTask="false" />
- startService(new Intent(getBaseContext(), OnClearFromRecentService.class));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement