1

私のコードでは、サウンド ファイルを着信音として設定しています。それはほとんど正常に動作します。

この問題は、着信音リストの着信音名に ContentValue の TITLE エントリが使用されていないことです。次のコードでは、TITLE キーを「Custom Name」に設定しています。しかし、着信音の選択リストでは、"testTone" (ファイル名は "testTone.mp3") として表示されることを主張しています。

// Take the given file and add it to the ringtone list
private Uri makeRingtone(File soundFile) {
  String path = soundFile.getAbsolutePath();

  // Make sure the system knows about it
  sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
          Uri.parse("file://"+path)));

  // Plug in same important values
  ContentValues values = new ContentValues();  
  values.put(MediaStore.MediaColumns.DATA, path);  
  values.put(MediaStore.MediaColumns.TITLE, "Custom Name");
  values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*"); 
  values.put(MediaStore.Audio.Media.IS_RINGTONE, true);  
  values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);  
  values.put(MediaStore.Audio.Media.IS_ALARM, true);  
  values.put(MediaStore.Audio.Media.IS_MUSIC, false);

  // The ol' delete then insert trick:
  Uri uri = MediaStore.Audio.Media.getContentUriForPath(path);
  getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + path + "\"", null);
  Uri newUri = getContentResolver().insert(uri, values);

  Log.d(TAG, "New Uri: " + newUri);

  return newUri;
}

これは問題に似ています:番号の場所の代わりにサウンドのタイトルを使用してサウンドを着信音として保存する

4

1 に答える 1