catch runtime exception when trying to stop tone manager

This commit is contained in:
Daniel Gultsch 2023-06-05 10:05:46 +02:00
parent 963f8ccee4
commit 6289e048b3
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -160,8 +160,17 @@ class ToneManager {
if (currentTone != null) { if (currentTone != null) {
currentTone.cancel(true); currentTone.cancel(true);
} }
if (toneGenerator != null) { stopTone(toneGenerator);
}
private static void stopTone(final ToneGenerator toneGenerator) {
if (toneGenerator == null) {
return;
}
try {
toneGenerator.stopTone(); toneGenerator.stopTone();
} catch (final RuntimeException e) {
Log.w(Config.LOGTAG,"tone has already stopped");
} }
} }