Nys
Nys

Reputation: 129

Get device volume in Xamarin Forms

Is it possible to read the volume level of an android device? There are 3 different volumes: Ringtone, music and alarm. I would like to find, if the music is muted. I've already tried AudioManager, but it doesn't seem to work properly on android SDK version 10 (if it works fine on your device, please let me know).

I've searched a lot and nothing seems to work, any suggestion will be appreciated 😉

Upvotes: 0

Views: 273

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

Android Q has changed the way applications access files in the external storage.

Before your app is fully compatible with scoped storage, you can temporarily opt out by using one of the following methods:

  1. Target Android 9 (API level 28) or lower.
  2. If you target Android 10 (API level 29) or higher, set the value of requestLegacyExternalStorage to true in your app's manifest file:
<manifest ... >
<!-- This attribute is "false" by default on apps targeting
     Android 10 or higher. -->
  <application android:requestLegacyExternalStorage="true" ... >
    ...
  </application>
</manifest>

For more details you could check Google Docs .

Upvotes: 1

Related Questions