android: update notification less frequently
This commit is contained in:
parent
c3864cb229
commit
f083546c7c
1 changed files with 9 additions and 3 deletions
|
@ -21,6 +21,8 @@ public class BackgroundService extends Service {
|
||||||
private static final int SYNC_STATUS_NOTIFICATION_ID = 1;
|
private static final int SYNC_STATUS_NOTIFICATION_ID = 1;
|
||||||
private NotificationCompat.Builder mNotificationBuilder;
|
private NotificationCompat.Builder mNotificationBuilder;
|
||||||
|
|
||||||
|
private String mNotificationContentText = "";
|
||||||
|
|
||||||
private final Runnable mUpdateSyncStatus = new Runnable() {
|
private final Runnable mUpdateSyncStatus = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -28,9 +30,13 @@ public class BackgroundService extends Service {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update sync status at notification.
|
// Update sync status at notification.
|
||||||
mNotificationBuilder.setContentText(getSyncStatusText());
|
String syncStatusText = getSyncStatusText();
|
||||||
|
if (!mNotificationContentText.equals(syncStatusText)) {
|
||||||
|
mNotificationContentText = syncStatusText;
|
||||||
|
mNotificationBuilder.setContentText(mNotificationContentText);
|
||||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||||
manager.notify(SYNC_STATUS_NOTIFICATION_ID, mNotificationBuilder.build());
|
manager.notify(SYNC_STATUS_NOTIFICATION_ID, mNotificationBuilder.build());
|
||||||
|
}
|
||||||
|
|
||||||
// Send broadcast to MainActivity if exit from the app is needed after node stop.
|
// Send broadcast to MainActivity if exit from the app is needed after node stop.
|
||||||
if (exitAppAfterNodeStop()) {
|
if (exitAppAfterNodeStop()) {
|
||||||
|
|
Loading…
Reference in a new issue