title: Notification of ForegroundService cancel not working
body: <p>I have a forground service, started by a binding activity. When the activity forast created the service, if user initiates the service, it will make it forground by calling below code</p>
  
  <pre><code>public void makeForgroundService() {
      notificationBuilder = new NotificationCompat.Builder(this);
      PendingIntent pendingIntent = PendingIntent.getActivity(this,
              sessionId, new Intent(this, MainActivity.class), 0);
      notificationBuilder.setContentTitle("My Test Service ")
              .setContentText("Service now Running")
              .setSmallIcon(R.drawable.newicon)
              .setContentIntent(pendingIntent);
      // notificationManager = (NotificationManager)
      // getSystemService(Context.NOTIFICATION_SERVICE);
      notify_id = sessionId;
      Log.e(TAG,"making foreGrounf : sessionId = "+String.valueOf(notify_id));
      startForeground(notify_id, notificationBuilder.build());
      isForeground = true;
  }
  </code></pre>
  
  <p>Now when activity is launched again , it is binding to the serive, (as already service is running and is forground) .  Now i wanna cancel the notification, tried it on getService call, but not working !</p>
  
  <pre><code>@Override
      public void onServiceConnected(ComponentName name, IBinder service) {
          // Log.e(TAG, "Inside onServiceConnected");
          myService = ((MyService.MyBinder) service).getService();
          if(myService.isForeground){
  
                      Log.e(TAG,"From Activity,removing notification : "+myService.notify_id);
  
                      NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
                      nm.cancel(myService.notify_id);
  
          }
      }
  </code></pre>
  
  <h1>Note</h1>
  
  <p>I dont want to <code>stopForground</code> of MyService. Just need to <strong>hide or cancel</strong> the notification.</p>
  
  <h2>Update:</h2>
  
  <p>If stopForground is the only way, will stopForground let the service liable to be killed during the activity is in foreground ? Can i set StartForground at onDestroy of activity? Is it a (<strong>right</strong>)way of doing this?</p>