StopForeground(true) does not stop the service and doesn't remove the notification

Viewed 36

For uploading files I create a foregroundservice, which should be removed when the upload is finished, but it doesn't get removed when I call this function:

 public void unbindServiceAndStop() throws Throwable{
    context.unbindService(serviceconnection);
    serviceconnection = null;
    context = null;
    stopForeground(true);
    //NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    //mNotificationManager.cancel(SERVICE_NOTIFICATION_ID);
    stopSelf();
}
0 Answers
Related