gpt4 book ai didi

Android - 设置短信声音不会改变声音?

转载 作者:行者123 更新时间:2023-11-29 00:40:05 25 4
gpt4 key购买 nike

我的问题是代码没有改变我的闹钟铃声,也没有改变我收到短信时的铃声。

以下作品:

       private void setRingTone(int RawId, String HumanName, String fileName)
{

Uri path = Uri.parse("android.resource://"+ getPackageName() +"/raw/" + fileName);

RingtoneManager.setActualDefaultRingtoneUri(
getApplicationContext(), RingtoneManager.TYPE_RINGTONE,
path);
Log .i("TESTT", "Ringtone Set to Resource: "+ path.toString());

RingtoneManager.getRingtone(getApplicationContext(), path)
.play();

}

但是这两个不:

  1. private void setTextTone(int RawId, String HumanName, String fileName) {

       Uri path = Uri.parse("android.resource://"+ getPackageName() +"/raw/" + fileName);

    RingtoneManager.setActualDefaultRingtoneUri(
    getApplicationContext(), RingtoneManager.TYPE_NOTIFICATION,
    path);
    Log .i("TESTT", "Ringtone Set to Resource: "+ path.toString());

    RingtoneManager.getRingtone(getApplicationContext(), path)
    .play();

有谁知道为什么通知不改变短信的声音,但铃声有效。基本上是一样的代码??

EDIT I found something on Stack Overflow here (But I do Not understand it can someone clarify?) http://stackoverflow.com/questions/9545906/how-do-i-change-the-android-sms-tone-despite-of-current-sms-tone-setting

提前致谢!

最佳答案

所以解决方案是将原始文件夹中的声音复制到 SD 卡中,然后从那里执行以下操作:

  File k = new File(path, filename);

ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, "TwiAppclip");
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
values.put(MediaStore.Audio.Media.ARTIST, "cssounds ");
values.put(MediaStore.Audio.Media.IS_RINGTONE, false);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
values.put(MediaStore.Audio.Media.IS_ALARM, false);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);

Uri uri = MediaStore.Audio.Media.getContentUriForPath(k
.getAbsolutePath());
//do a delete here before inserting
Uri newUri = getApplicationContext().getContentResolver().insert(uri, values);

RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(),
RingtoneManager.TYPE_RINGTONE, newUri);

关于Android - 设置短信声音不会改变声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9967812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com