mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Merge pull request #372 from meskio/key_notification
Upgrade notification KeyCachingService code to use NotificationCompat.Builder
This commit is contained in:
commit
2cbc4d3b0a
@ -189,7 +189,7 @@ public class KeyCachingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void foregroundServiceModern() {
|
private void foregroundServiceModern() {
|
||||||
Notification notification = new Notification(R.drawable.icon_cached, null, System.currentTimeMillis());
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
||||||
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.key_caching_notification);
|
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.key_caching_notification);
|
||||||
|
|
||||||
Intent intent = new Intent(this, KeyCachingService.class);
|
Intent intent = new Intent(this, KeyCachingService.class);
|
||||||
@ -197,10 +197,11 @@ public class KeyCachingService extends Service {
|
|||||||
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
|
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, intent, 0);
|
||||||
remoteViews.setOnClickPendingIntent(R.id.lock_cache_icon, pendingIntent);
|
remoteViews.setOnClickPendingIntent(R.id.lock_cache_icon, pendingIntent);
|
||||||
|
|
||||||
notification.contentView = remoteViews;
|
builder.setSmallIcon(R.drawable.icon_cached);
|
||||||
|
builder.setContent(remoteViews);
|
||||||
|
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
startForeground(SERVICE_RUNNING_ID, notification);
|
startForeground(SERVICE_RUNNING_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void foregroundServiceLegacy() {
|
private void foregroundServiceLegacy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user