使用 activity 获取设备铃声并 运行

Get ringtone of device and run it with activity

如何获取 android 设备的铃声并在 Activity 中设置(当 activity 自动启动设备 运行 的铃声时)

    Uri defaultRintoneUri = RingtoneManager.getActualDefaultRingtoneUri(getActivity().getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
    Ringtone defaultRingtone = RingtoneManager.getRingtone(getActivity(), defaultRintoneUri);
    defaultRingtone.play();