Clear notification when service destroyed

This commit is contained in:
PeratX 2017-04-10 15:47:09 +08:00
parent a22c0454e4
commit bb976ba50f

View File

@ -128,9 +128,6 @@ public class DaedalusVpnService extends VpnService implements Runnable {
case ACTION_DEACTIVATE:
stopThread();
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ACTIVATED);
notification = null;
return START_NOT_STICKY;
}
@ -156,6 +153,10 @@ public class DaedalusVpnService extends VpnService implements Runnable {
Os.close(mBlockFd);
this.mThread = null;
}
if (notification != null) {
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ACTIVATED);
}
} catch (Exception e) {
Log.d(TAG, e.toString());
}