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();
}