Well, I'm not sure if my solution is best practice. Using the NotificationBuilder
my code looks like that:
private void showNotification() {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
Manifest:
<activity
android:name=".MainActivity"
android:launchMode="singleInstance"
</activity>
and here the Service:
<service
android:name=".services.ProtectionService"
android:launchMode="singleTask">
</service>
I don't know if there really is a singleTask
at Service
but this works properly at my application...