本文整理汇总了Java中android.media.RingtoneManager.setType方法的典型用法代码示例。如果您正苦于以下问题:Java RingtoneManager.setType方法的具体用法?Java RingtoneManager.setType怎么用?Java RingtoneManager.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.RingtoneManager
的用法示例。
在下文中一共展示了RingtoneManager.setType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例8: initView
import android.media.RingtoneManager; //导入方法依赖的package包/类
private void initView() {
final RadioGroup group = (RadioGroup) getView().findViewById(
R.id.ringtoneGroup);
RingtoneManager manager = new RingtoneManager(getActivity());
manager.setType(RingtoneManager.TYPE_RINGTONE);
int pdng = (int) (5 * getResources().getDisplayMetrics().density + .5f);
final String[] columns = {MediaStore.Images.Media.DATA,
MediaStore.Audio.Media._ID};
final String orderBy = MediaStore.Images.Media._ID;
Cursor imagecursor = getActivity().getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy);
int dataColumnIndex = imagecursor
.getColumnIndex(MediaStore.Audio.Media.DATA);
for (int i = 0; i < imagecursor.getCount(); i++) {
imagecursor.moveToPosition(i);
final String uri = imagecursor.getString(dataColumnIndex);
final String title = uri.substring(uri.lastIndexOf("/") + 1);
RadioButton rb = new RadioButton(getActivity());
rb.setLayoutParams(new RadioGroup.LayoutParams(
RadioGroup.LayoutParams.MATCH_PARENT,
RadioGroup.LayoutParams.WRAP_CONTENT));
rb.setText(title);
rb.setTypeface(((OneSheeldApplication) getActivity()
.getApplication()).appFont);
rb.setGravity(Gravity.CENTER);
rb.setPadding(pdng, pdng, pdng, pdng);
rb.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
rb.setTextColor(getResources().getColor(R.color.textColorOnDark));
rb.setBackgroundResource(R.drawable.devices_list_item_selector);
rb.setTag(uri);
rb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((OneSheeldApplication) getActivity().getApplication())
.setBuzzerSound(uri);
}
});
group.addView(rb);
}
}