【问题标题】:I want to access my System default Ringtone's name我想访问我的系统默认铃声的名称
【发布时间】:2022-11-11 12:21:10
【问题描述】:

我是 kotlin/android 开发的新手,我想访问我的系统默认铃声名称并将其显示在字符串中,我该怎么做?

【问题讨论】:

    标签: android flutter kotlin


    【解决方案1】:
    data class NotificationSoundDataModel(
        val soundName: String? = null,
        val soundUri: String? = null
    )
    
    private fun getRingtoneList(): ArrayList<NotificationSoundDataModel> {
        val notificationList = ArrayList<NotificationSoundDataModel>()
        val manager = RingtoneManager(context).apply {
            setType(RingtoneManager.TYPE_NOTIFICATION)
        }
        val cursor: Cursor = manager.cursor
        while (cursor.moveToNext()) {
            val title: String = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX)
            val uri: String =
                cursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/" + cursor.getString(
                    RingtoneManager.ID_COLUMN_INDEX
                ) + "?title=" + cursor.getString(
                    RingtoneManager.TITLE_COLUMN_INDEX
                )
    
            notificationList.add(NotificationSoundDataModel(title, uri))
        }
        return notificationList
    }
    

    参考:https://medium.com/@rathorerahul586/android-change-notification-sound-93eb4fd4ece5

    【讨论】:

      猜你喜欢
      • 2021-12-29
      • 2014-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多