0

How can we get current user settings like phone ringtone & ring volume, Current wallpaper, vibration, etc setting programmatically?

I want to store them & set them back whenever user wants to.....

I am new to kotlin.

Bhuro
  • 348
  • 4
  • 22

2 Answers2

0

You can use below code for your purpose.

For getting ringtone:

val defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(getActivity().getApplicationContext(), RingtoneManager.TYPE_RINGTONE)
        val defaultRingtone = RingtoneManager.getRingtone(getActivity(), defaultRingtoneUri)

For getting ringtone volume:

  val am = getSystemService(AUDIO_SERVICE) as AudioManager
        val volume_level = am.getStreamVolume(AudioManager.STREAM_MUSIC)

For getting current wallpaper:

 val  wallpaperManager = WallpaperManager.getInstance(this) as WallpaperManager
            val wallpaperDrawable: Drawable = wallpaperManager.getDrawable()
Lokesh Desai
  • 2,607
  • 16
  • 28
  • How can I set them back ? Do i need to save `defaultRingtone` as file? or I can get file path to set it back? – Bhuro Mar 24 '18 at 06:48
  • u will get file path and u can set it back setRingtone method..use sharepref to store data or local database..u can also use file also as u mentioned – Lokesh Desai Mar 24 '18 at 07:14
0

For Ringtone you can use RingtoneManager and get the default ringtone with RingtoneManager.getActualDefaultRingtoneUri(Context context, int type)

For Volume you can use AudioManager.

AudioManager.getStreamVolume(AudioManager.STREAM_RING)

For Wallpaper you can user WallpaperManager.

WallpaperManager.getDrawable() -> //Retrieve the current system wallpaper.

If you need any other information please try to use stackoverflow search function or simply google search.

Good luck!

Robert Banyai
  • 1,329
  • 12
  • 14