Function

```
private void startService() {
        if (!onForeground) {
            Log.d(Constants.TAG, "RecordService startService");
            Intent intent = new Intent(this, MainActivity.class);
            // intent.setAction(Intent.ACTION_VIEW);
            // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            PendingIntent pendingIntent = PendingIntent.getActivity(
                    getBaseContext(), 0, intent, 0);

            Notification notification = new NotificationCompat.Builder(
                    getBaseContext())
                    .setContentTitle(
                            this.getString(R.string.notification_title))
                    .setTicker(this.getString(R.string.notification_ticker))
                    .setContentText(this.getString(R.string.notification_text))
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setContentIntent(pendingIntent).setOngoing(false)
                    .getNotification();

            notification.flags = Notification.FLAG_AUTO_CANCEL;

            startForeground(1337, notification);
            onForeground = false;
        }
    }

```

what should I do that i notifiction is cancalable when i want to remove it from notification.. i am new to android so plz help me
['https://Stackoverflow.com/questions/38042541', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5702485/']
Notifications associated with a foreground service are ongoing, i.e., not cancelable. You should provide a separate action in the notification to cancel the notification (which would have to call [stopForeground()](https://developer.android.com/reference/android/app/Service.html#stopForeground(boolean)) to remove the notification).
Add a ID in your Notification builder, after this set notification.cancel (id);