I'm just going to paste my code here. There's too much to discuss it in detail. Hopefully you'll just see the bit you have been missing, or what you might need to change in your own code, so that I don't have to do that for you.
function TMainService.AndroidServiceStartCommand(const Sender: TObject;
const Intent: JIntent; Flags, StartId: Integer): Integer;
var
ExtraData: String;
{$ifdef FOREGROUND}
NewIntent: JIntent;
ncb: JNotificationCompat_Builder;
ntf: JNotification;
PendingIntent: JPendingIntent;
{$endif}
begin
// called EVERY TIME the service starts or automatically restarts
LogMe('Startservice called');
// Using NOT STICKY so the service gets automatically closed when the host closes
// not need to try stopservice anymore :-)
Result := TJService.JavaClass.START_NOT_STICKY;
{$ifdef FOREGROUND}
{$ifdef ORDINARY_NOTIFICATION}
// unclickable
PendingIntent := TJPendingIntent.JavaClass.getActivity(
JavaService.getApplicationContext, 0, Intent, 0
);
ntf := TJNotification.Create;
ntf.icon := JavaService.getApplicationInfo.icon;
ntf.setLatestEventInfo(
JavaService.getApplicationContext,
StrToJCharSequence('Tracker Service'),
StrToJCharSequence('Communications Service'), PendingIntent);
{$else}
// ALL THIS code is to make the host come to foreground when the user taps
// the permanent notification
// thanks to:
// https://forums.embarcadero.com/message.jspa?messageID=847227
// https://gist.github.com/kristopherjohnson/6211176
NewIntent:= TAndroidHelper.Context.getPackageManager().getLaunchIntentForPackage(
TAndroidHelper.Context.getPackageName());
NewIntent.setAction(TJIntent.JavaClass.ACTION_MAIN);
NewIntent.addCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER);
NewIntent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
PendingIntent := TJPendingIntent.JavaClass.getActivity(
TAndroidHelper.Context, 0, NewIntent,
TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK
);
ncb := TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context);
ncb.setContentTitle(StrToJCharSequence('GroupTracker Service'));
ncb.setTicker(StrToJCharSequence('Communications Service'));
ncb.setSmallIcon(JavaService.getApplicationInfo.icon);
ncb.setContentIntent(PendingIntent);
ncb.setOngoing(True);
ntf := ncb.build;
{$endif}
LogMe('Start foreground called');
JavaService.startForeground(StartId, ntf);
{$endif}
{$ifdef STOPSELF}
LogMe('stopSelf');
// this actually queues the stop request until the host stops running
// almost like START_NOT_STICKY really
JavaService.stopSelf(StartId);
// using unbind and stop instead, thanks
{$endif}
if Intent <> nil then
begin
ExtraData := TAndroidHelper.JStringToString(
Intent.getStringExtra(TAndroidHelper.StringToJString('ExtraData')));
LogMe('ExtraData=' + Extradata);
end;
end;