本文整理匯總了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();
}
}