Suite à this tutorial, j'ai implémenté un lecteur audio dans mon application. Cependant, une notification s'affiche automatiquement sur un appareil Wear, dont je ne veux pas. Je l'ai réduit à ce code:Empêcher la notification d'usure à l'aide de PlaybackStateCompat
PlaybackStateCompat.Builder playbackstateBuilder = new PlaybackStateCompat.Builder();
if (state == PlaybackStateCompat.STATE_PLAYING) {
playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PAUSE);
} else {
playbackstateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY);
}
playbackstateBuilder.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 0);
mMediaSessionCompat.setPlaybackState(playbackstateBuilder.build());
spécifiquement la dernière ligne est l'endroit où la notification s'affiche. Si je commente cette ligne, la notification ne s'affiche pas, mais mon application ne répond plus aux commandes de média externes.