mapbox / mapbox/mapbox-navigation-android

Listen for Voice Guidance Muted Changes

Open
#4,264 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jira-sync-complete
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Android API: 29**
**Mapbox Navigation SDK version: 1.5.1**

I'm trying to get my application to persist whether or not the voice guidance is muted. However, there is no organic way to detect when voice guidance changes from being muted to unmuted or vice versa.

The only way, that I've found, to detect this is to use `navigationView.retrieveSoundButton().addOnClickListener` to trigger when the button has been pressed, indicating a change whether or not voice guidance is muted, and then use `navigationView.isVoiceGuidanceMuted()` to get its updated value. This, however, does not always work. Sometimes the call to `navigationView.isVoiceGuidanceMuted()` does not reflect the new value. I suspect this is because the `OnClickListener` is being called too early. So the final code would look something like this

```java
navigationView.retrieveSoundButton().addOnClickListener(v -> {
handler.postDelayed(() -> {
muteVoiceGuidance = navigationView.isVoiceGuidanceMuted();
prefs.edit().putBoolean("muteVoiceGuidance", muteVoiceGuidance).apply();
Log.v("MapBox", "MuteVoiceGuidance: " + muteVoiceGuidance);
}, 250);
});
```

and then starting navigation like this:

```java
NavigationViewOptions options = NavigationViewOptions.builder(this)
...
.muteVoiceGuidance(muteVoiceGuidance)
.build();
navigationView.startNavigation(options);
```

## Suggestion

Add a method `void addVoiceGuidanceMuteChangeListener(VoiceGuidanceMuteChangeListener listener)` to `NavigationView` where `VoiceGuidanceMuteChangeListener` could be defined as:

```java
@FunctionalInterface
public interface VoiceGuidanceMuteChangeListener {
void onVoiceGuidanceMuteChange(boolean isVoiceGuidanceMuted);
}
```

---

If there is another way to achieve this, then I apologize for the inconvenience.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at NavigationView's sound-button handling and the isVoiceGuidanceMuted() state, then trace how NavigationViewOptions.muteVoiceGuidance is applied when navigation starts. Done means callers can reliably receive the updated mute value whenever voice guidance changes in either direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.