Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SDK problem setting ringtone
    primarykey
    data
    text
    <p>I am trying to add and set the default ringtone on the emulator/phone. The ringtone has been downloaded and is stored in the application folder /dada/dada/com.xxx/ringtones. the ringtones are ogg files.</p> <p>I use the following code to add and set the ringtone:</p> <pre><code>public void setRingtone() { aajoAsset asset = null; asset = mXXXX.getAssetManager().getCurrentRingtoneAsset(); if (asset != null &amp;&amp; asset.isSaved()/* &amp;&amp; !asset.getName().equals(mLastAssetName)*/) { String filepath = asset.getDirectoryPath() + asset.getFilename(); File ringtoneFile = new File(filepath); if (LOG) { Log.i(TAG, "Sending Intent : " + Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); } mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + asset.getDirectoryPath() + asset.getFilename()))); ContentValues content = new ContentValues(); content.put(MediaStore.MediaColumns.DATA,ringtoneFile.getAbsolutePath()); content.put(MediaStore.MediaColumns.TITLE, "1234"); content.put(MediaStore.MediaColumns.SIZE, asset.getSize()); content.put(MediaStore.MediaColumns.MIME_TYPE, "audio/ogg"); content.put(MediaStore.Audio.Media.ARTIST, "1234"); content.put(MediaStore.Audio.Media.DURATION, 4800); content.put(MediaStore.Audio.Media.IS_RINGTONE, true); content.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); content.put(MediaStore.Audio.Media.IS_ALARM, false); content.put(MediaStore.Audio.Media.IS_MUSIC, false); if (LOG) { Log.i(TAG, "the absolute path of the file is : " + ringtoneFile.getAbsolutePath()); } Uri uri = MediaStore.Audio.Media.getContentUriForPath( ringtoneFile.getAbsolutePath()); Uri newUri = mContext.getContentResolver().insert(uri, content); if (LOG) { Log.i(TAG,"the ringtone uri is : " + newUri); } RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_RINGTONE, newUri); mLastAssetName = asset.getName(); } </code></pre> <p>The code executes fine and the ringtone shows in the ringtone list but when I click on it to test it or when I simulate a incoming call I get the following errors in LogCat:</p> <pre><code>DEBUG/MediaPlayer(1230): Couldn't open file on client side, trying server side ERROR/MediaPlayerService(33): Couldn't open fd for content://media/internal/audio/media/1 ERROR/MediaPlayer(1230): Unable to to create media player ERROR/RingtoneManager(1230): Failed to open ringtone content://media/internal/audio/media/1 </code></pre> <p>I have searched for solutions in many forums and cannot find any.</p> <p>any help is most welcome</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload