本文整理汇总了Java中android.media.RingtoneManager.getRingtoneUri方法的典型用法代码示例。如果您正苦于以下问题:Java RingtoneManager.getRingtoneUri方法的具体用法?Java RingtoneManager.getRingtoneUri怎么用?Java RingtoneManager.getRingtoneUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.RingtoneManager
的用法示例。
在下文中一共展示了RingtoneManager.getRingtoneUri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNotifications
import android.media.RingtoneManager; //导入方法依赖的package包/类
public Map<String, String> getNotifications() {
RingtoneManager manager = new RingtoneManager(getActivity());
manager.setType(RingtoneManager.TYPE_NOTIFICATION);
Cursor cursor = manager.getCursor();
Map<String, String> list = new HashMap<>();
while (cursor.moveToNext()) {
String notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
Uri notificationUri = manager.getRingtoneUri(cursor.getPosition());
list.put(notificationTitle, notificationUri.toString());
}
list.put(getString(R.string.ringtone_vk), Settings.get()
.notifications()
.getDefNotificationRingtone());
return list;
}
示例2: searchAlarmUri
import android.media.RingtoneManager; //导入方法依赖的package包/类
private Uri searchAlarmUri(int alarmId) {
Context context = MBApp.getApp();
RingtoneManager ringtoneMgr = new RingtoneManager(context);
ringtoneMgr.setType(RingtoneManager.TYPE_ALARM);
Cursor alarms = ringtoneMgr.getCursor();
Log.i(TAG, "playAlarm: total alarms = " + alarms.getCount());
alarms.moveToPosition(alarmId - 4);
Uri alarm = ringtoneMgr.getRingtoneUri(alarms.getPosition());
if(alarm == null) {
Log.i(TAG, "Cannot play nth Alarm. Playing default");
alarm = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
}
return alarm;
}
示例3: startPlayingRing
import android.media.RingtoneManager; //导入方法依赖的package包/类
private void startPlayingRing() {
RingtoneManager ringtoneManager = new RingtoneManager(this);
ringtoneManager.setType(RingtoneManager.TYPE_ALARM);
ringtoneManager.getCursor();
Uri ringtoneUri = ringtoneManager.getRingtoneUri(alarm.ringPosition);
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 7, AudioManager.ADJUST_SAME);
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(this, ringtoneUri);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setLooping(true);
} catch (IOException e) {
e.printStackTrace();
}
}