MediaPlayer setDataSource failed with status=0x80000000 for Ringtone set by filepath on 2.3.4

Answer by Lorne below was most helpful when dealing with this problem. For anyone else struggling with it, here is the code that I have been using for over 6 months now with errors almost not reported anymore. fileinfo can be both of below (examples): /system/media/audio/alarms/Walk_in_the_forest.ogg content://media/internal/audio/media/20 public static void setMediaPlayerDataSource(Context context, MediaPlayer mp, String … Read more

Setting contact custom ringtone, how?

I found out how it works. Below you can see the fixed code code: Uri contactData = ContactsContract.Contacts.CONTENT_URI; String contactId = contactData.getLastPathSegment(); Cursor localCursor = managedQuery(contactData, PROJECTION, null, null, null); localCursor.move(120/*CONTACT ID NUMBER*/); String str1 = localCursor.getString(localCursor.getColumnIndexOrThrow(“_id”)); String str2 = localCursor.getString(localCursor.getColumnIndexOrThrow(“display_name”)); Uri localUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, str1); ContentValues localContentValues = new ContentValues(); localContentValues.put(ContactsContract.Data.RAW_CONTACT_ID, contactId); localContentValues.put(ContactsContract.Data.CUSTOM_RINGTONE, f.getAbsolutePath()+”/Adventure.ogg”); … Read more

How can I change the ringtone in android programmatically?

The below code choose any random tone from the mobile for Incoming call. RingtoneManager rm = new RingtoneManager(context); Random random = new Random(); int i = rm.getRingtonePosition(RingtoneManager .getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE)); MyApplication.APPLICATION_SHARED_PREFERENCE.edit() .putInt(MyConstants.PHONE_RINGTONE_NUMBER, i).commit(); int chanegToneNumber; Cursor cursor = rm.getCursor(); while (true) { chanegToneNumber = random.nextInt(cursor.getCount()); if (chanegToneNumber != i) break; } Log.d(TAG, “Tone: ” + i); … Read more

How to set ringtone with RingtoneManager.ACTION_RINGTONE_PICKER?

You must implement onActivityResult() to receive result from user’s pick, then save it. if (resultCode == RESULT_OK) { Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { String ringTonePath = uri.toString(); } Here an example: http://www.ceveni.com/2009/07/ringtone-picker-in-android-with-intent.html EDIT: update RingtoneManager.setActualDefaultRingtoneUri( myActivity, RingtoneManager.TYPE_RINGTONE, uri); You must call this 🙂

setting audio file as Ringtone

Audio is set as ringtone only once, but solution to this problem is – If you are trying to run the same code again, you’ll be inserting a duplicate entry into MediaStore’s table, but the SQLite database won’t allow you. You have to either rename your file and add another instance of it, or go … Read more

How to set ringtone in Android from my activity?

Finally, I managed to set the default ringtone to one that i downloaded. The download code is not included below, only what was needed to set it as default ringtone. File k = new File(path, “mysong.mp3”); // path is a file to /sdcard/media/ringtone ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, “My Song title”); values.put(MediaStore.MediaColumns.SIZE, … Read more