我想更改默认系统警报声音,我想使用:
Uri uri =Uri.parse("android.resource://com.aa.Uhome9110/raw/"+"alarm_buzzer");
RingtoneManager.setActualDefaultRingtoneUri(EditRingActivity.this, RingtoneManager.TYPE_ALARM, uri);
但没有效果。
我用过:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "alarm");
startActivityForResult(intent, 2);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != RESULT_OK)
{
return;
}
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
Log.i("uri ","uri11 "+uri.toString());
if (uri != null)
{
switch (requestCode)
{
case 1:
RingtoneManager.setActualDefaultRingtoneUri(this,
RingtoneManager.TYPE_RINGTONE, uri);
break;
case 2:
RingtoneManager.setActualDefaultRingtoneUri(this,
RingtoneManager.TYPE_ALARM, uri);
break;
case 3:
RingtoneManager.setActualDefaultRingtoneUri(this,
RingtoneManager.TYPE_NOTIFICATION, uri);
}
}
}
一切都好,我认为我的 uri 是错误的,所以我修改:
Uri uri =Uri.parse("content://media/internal/audio/media/4");
RingtoneManager.setActualDefaultRingtoneUri(EditRingActivity.this, RingtoneManager.TYPE_ALARM, uri);
但没用。我不认为用startActivityForResult(intent, 2)方法,我想直接改变系统警报,你能给我一些建议吗?