本文整理了Java中android.media.RingtoneManager.setActualDefaultRingtoneUri
方法的一些代码示例,展示了RingtoneManager.setActualDefaultRingtoneUri
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RingtoneManager.setActualDefaultRingtoneUri
方法的具体详情如下:
包路径:android.media.RingtoneManager
类名称:RingtoneManager
方法名:setActualDefaultRingtoneUri
暂无
代码示例来源:origin: google/ringdroid
private void setAsDefaultRingtoneOrNotification(){
Cursor c = mAdapter.getCursor();
// If the item is a ringtone then set the default ringtone,
// otherwise it has to be a notification so set the default notification sound
if (0 != c.getInt(c.getColumnIndexOrThrow(MediaStore.Audio.Media.IS_RINGTONE))){
RingtoneManager.setActualDefaultRingtoneUri(
RingdroidSelectActivity.this,
RingtoneManager.TYPE_RINGTONE,
getUri());
Toast.makeText(
RingdroidSelectActivity.this,
R.string.default_ringtone_success_message,
Toast.LENGTH_SHORT)
.show();
} else {
RingtoneManager.setActualDefaultRingtoneUri(
RingdroidSelectActivity.this,
RingtoneManager.TYPE_NOTIFICATION,
getUri());
Toast.makeText(
RingdroidSelectActivity.this,
R.string.default_notification_success_message,
Toast.LENGTH_SHORT)
.show();
}
}
代码示例来源:origin: google/ringdroid
public void handleMessage(Message response) {
int actionId = response.arg1;
switch (actionId) {
case R.id.button_make_default:
RingtoneManager.setActualDefaultRingtoneUri(
RingdroidEditActivity.this,
RingtoneManager.TYPE_RINGTONE,
newUri);
Toast.makeText(
RingdroidEditActivity.this,
R.string.default_ringtone_success_message,
Toast.LENGTH_SHORT)
.show();
finish();
break;
case R.id.button_choose_contact:
chooseContactForRingtone(newUri);
break;
default:
case R.id.button_do_nothing:
finish();
break;
}
}
};
代码示例来源:origin: recoilme/freemp
public static void setRingtone(Context context, ClsTrack track) {
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, track.getPath());
values.put(MediaStore.MediaColumns.TITLE, track.getTitle());
//values.put(MediaStore.MediaColumns.SIZE, 1024*1024);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
values.put(MediaStore.Audio.Media.ARTIST, track.getArtist());
//values.put(MediaStore.Audio.Media.DURATION, 5000);
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
values.put(MediaStore.Audio.Media.IS_ALARM, false);
values.put(MediaStore.Audio.Media.IS_MUSIC, true);
Uri uri = MediaStore.Audio.Media.getContentUriForPath(track.getPath());
if (uri == null || context.getContentResolver() == null) {
Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show();
return;
}
//TODO check this may be better copy file in ringtone dir before?
context.getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + track.getPath() + "\"", null);
Uri newUri = context.getContentResolver().insert(uri, values);
if (newUri == null) {
Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show();
} else {
RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, newUri);
Toast.makeText(context, context.getString(R.string.set_as_ringtone), Toast.LENGTH_SHORT).show();
}
}
代码示例来源:origin: geniusgithub/AndroidDialer
@Override
protected void onSaveRingtone(Uri ringtoneUri) {
if (!SettingsCompat.System.canWrite(getContext())) {
Toast.makeText(
getContext(),
getContext().getResources().getString(R.string.toast_cannot_write_system_settings),
Toast.LENGTH_SHORT).show();
return;
}
RingtoneManager.setActualDefaultRingtoneUri(getContext(), getRingtoneType(), ringtoneUri);
}
代码示例来源:origin: yangchong211/YCAudioPlayer
/**
* 设置铃声
*/
private void setRingtone(AudioBean localMusic) {
Uri uri = MediaStore.Audio.Media.getContentUriForPath(localMusic.getPath());
// 查询音乐文件在媒体库是否存在
Cursor cursor = getContext().getContentResolver().query(uri, null,
MediaStore.MediaColumns.DATA + "=?", new String[]{localMusic.getPath()}, null);
if (cursor == null) {
return;
}
if (cursor.moveToFirst() && cursor.getCount() > 0) {
String _id = cursor.getString(0);
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Media.IS_MUSIC, true);
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
values.put(MediaStore.Audio.Media.IS_ALARM, false);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
values.put(MediaStore.Audio.Media.IS_PODCAST, false);
getContext().getContentResolver().update(uri, values, MediaStore.MediaColumns.DATA + "=?",
new String[]{localMusic.getPath()});
Uri newUri = ContentUris.withAppendedId(uri, Long.valueOf(_id));
RingtoneManager.setActualDefaultRingtoneUri(getContext(), RingtoneManager.TYPE_RINGTONE, newUri);
ToastUtils.showShort("设置铃声成功");
}
cursor.close();
}
内容来源于网络,如有侵权,请联系作者删除!