Do not show service running notification on onCreate
Sometimes (Bluetooth/Android Auto), the service is created and then just bound to. That means that onStartCommand is never called. This causes a persistent notification. Just in case the notification is somehow still shown to users, modified the message to tell them how to hide it.
This commit is contained in:
parent
1fc7352702
commit
0b60a8acee
|
@ -269,7 +269,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
|
|
||||||
stateManager = new PlaybackServiceStateManager(this);
|
stateManager = new PlaybackServiceStateManager(this);
|
||||||
notificationBuilder = new PlaybackServiceNotificationBuilder(this);
|
notificationBuilder = new PlaybackServiceNotificationBuilder(this);
|
||||||
stateManager.startForeground(R.id.notification_playing, notificationBuilder.build());
|
|
||||||
|
|
||||||
registerReceiver(autoStateUpdated, new IntentFilter("com.google.android.gms.car.media.STATUS"));
|
registerReceiver(autoStateUpdated, new IntentFilter("com.google.android.gms.car.media.STATUS"));
|
||||||
registerReceiver(headsetDisconnected, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
|
registerReceiver(headsetDisconnected, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class PlaybackServiceNotificationBuilder {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notification.setContentTitle(context.getString(R.string.app_name));
|
notification.setContentTitle(context.getString(R.string.app_name));
|
||||||
notification.setContentText("Service is running");
|
notification.setContentText("Loading. If this does not go away, play any episode and contact us.");
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.setContentIntent(getPlayerActivityPendingIntent());
|
notification.setContentIntent(getPlayerActivityPendingIntent());
|
||||||
|
|
Loading…
Reference in New Issue