本文整理汇总了Java中android.media.RingtoneManager.getCursor方法的典型用法代码示例。如果您正苦于以下问题:Java RingtoneManager.getCursor方法的具体用法?Java RingtoneManager.getCursor怎么用?Java RingtoneManager.getCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.RingtoneManager
的用法示例。
在下文中一共展示了RingtoneManager.getCursor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getTone
import android.media.RingtoneManager; //导入方法依赖的package包/类
/**
* Get the tone from {@link RingtoneManager} for any given type. It will add title as the key and
* uri of the sound as value in given hashmap.
*
* @param context instance of the caller
* @param type type of the ringtone from {@link RingtonePickerDialog.Builder#TYPE_NOTIFICATION},
* {@link RingtonePickerDialog.Builder#TYPE_RINGTONE} or {@link RingtonePickerDialog.Builder#TYPE_ALARM}
* @param ringTonesList Hash map in which alarm tone will be added.
*/
private static void getTone(Context context,
int type,
@NonNull HashMap<String, Uri> ringTonesList) {
RingtoneManager mRingtoneMgr = new RingtoneManager(context);
mRingtoneMgr.setType(type);
Cursor ringsCursor = mRingtoneMgr.getCursor();
while (ringsCursor.moveToNext()) {
ringTonesList.put(ringsCursor.getString(RingtoneManager.TITLE_COLUMN_INDEX),
Uri.parse(ringsCursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/"
+ ringsCursor.getString(RingtoneManager.ID_COLUMN_INDEX)));
}
ringsCursor.close();
}
示例4: showRingList
import android.media.RingtoneManager; //导入方法依赖的package包/类
private List<String> showRingList(Context context) {
List<String> ringNameList = new ArrayList<>();
RingtoneManager ringtoneManager = new RingtoneManager(context);
ringtoneManager.setType(RingtoneManager.TYPE_ALARM);
Cursor cursor = ringtoneManager.getCursor();
while (cursor.moveToNext()) {
String ringName = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
ringNameList.add(ringName);
}
return ringNameList;
}
示例5: firstRing
import android.media.RingtoneManager; //导入方法依赖的package包/类
private String firstRing(Context context) {
RingtoneManager ringtoneManager = new RingtoneManager(context);
ringtoneManager.setType(RingtoneManager.TYPE_ALARM);
Cursor cursor = ringtoneManager.getCursor();
String ringName = null;
while (cursor.moveToNext()) {
ringName = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
if (ringName != null) {
break;
}
}
cursor.close();
return ringName;
}
示例6: 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();
}
}
示例7: firstRing
import android.media.RingtoneManager; //导入方法依赖的package包/类
private String firstRing(Context context) {
RingtoneManager ringtoneManager = new RingtoneManager(context);
ringtoneManager.setType(RingtoneManager.TYPE_ALARM);
Cursor cursor = ringtoneManager.getCursor();
String ringName = null;
while (cursor.moveToNext()) {
ringName = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
if (ringName != null) {
break;
}
}
return ringName;
}