ringtone

How to get current ringtone in Android?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 03:21:01
问题 I have found lots of examples how to get default ringtone. Something like that: Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), alert); ringtone.setStreamType(AudioManager.STREAM_RING); ringtone.play(); But I want to get the actual current ringtone, that was set by the user. 回答1: I was struggling with this issue as well, so the solution is: Uri defaultRingtoneUri = RingtoneManager

Setting Ringtone notification from SD card file

孤者浪人 提交于 2019-11-26 23:25:52
问题 My goal is to set the users notification sound from a file that is stored onto the SD card from with in the application. I am using this code: if(path != null){ File k = new File(path, "moment.mp3"); ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "My Song title"); values.put(MediaStore.MediaColumns.SIZE, 215454); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put

How can I change the ringtone in android programmatically?

倖福魔咒の 提交于 2019-11-26 20:34:56
问题 I'm trying to write an app that (among other things) will change the user's ringtone based on their location. However, I'm having difficulty setting the ringtone of my phone from within my app. I've been able to display a list of the phone's ringtones, and have been using the following code to try and set the ringtone: RingtoneManager.setActualDefaultRingtoneUri(applicationContext, RingtoneManager.TYPE_RINGTONE, MediaStore.Audio.Media.getContentUriForPath(settings.getRingtoneURI())); Settings

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

笑着哭i 提交于 2019-11-26 18:13:36
问题 Title says most of it. My application has been playing ringtones pointed by uri like content://media/internal/audio/media/387 or content://media/external/audio/media/1655 (for custom ringtones on SDcard I believe) using both setDataSource(fileInfo) and setDataSource(mContext, Uri.parse(fileInfo)) . In each case I have received logs with information about setDataSource failed.: status=0x80000000 exception on phones using Android 4.x (different versions). Seeing that the error happens only to

Setting contact custom ringtone, how?

我的未来我决定 提交于 2019-11-26 16:47:43
问题 I know how to change phone ringtone, also how to get contacts, but how can I set a ringtone for a specific contact? So how do I use the method: ContactsContract.Contacts.CUSTOM_RINGTONE ? I have tried it like this: Uri contactUri = ContactsContract.Contacts.CONTENT_URI; String[] PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.HAS_PHONE_NUMBER, }; String SELECTION = ContactsContract.Contacts.HAS_PHONE_NUMBER + "='1'";

Setting Ringtone in Android [duplicate]

隐身守侯 提交于 2019-11-26 14:25:55
Possible Duplicate: How to set ringtone in Android from my activity? I have sounds files in my res/raw folder and i want to select a sound to set as a ringtone on the click of a button. Wonder how can i do that? Chiatar @Maxood The code from @Clive is what you need to set the ringtone. You will need the absolute path to the file, which you can't get from a raw resource. The solution is to get the resource file asset and write it to the sdcard 1st, before you give it to the content resolver for insertion. File newSoundFile = new File("/sdcard/media/ringtone", "myringtone.oog"); Uri mUri = Uri

setting audio file as Ringtone

ぐ巨炮叔叔 提交于 2019-11-26 12:07:31
问题 I have save file in sdcard/media/audio/ringtone s folder. That file will appear in list of ringtone selection from settings/sound/phone Ringtone. But I want to set that file as a ringtone from my code. Here is my code. 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

How to set ringtone with RingtoneManager.ACTION_RINGTONE_PICKER?

安稳与你 提交于 2019-11-26 10:52:14
问题 I try to find solution here, but there are only solution for own/selected file, not for code when I call picker. I use following code when user press button: Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, \"Select ringtone for notifications:\"); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); intent.putExtra(RingtoneManager.EXTRA

How to set ringtone in Android from my activity?

走远了吗. 提交于 2019-11-26 00:17:51
问题 I\'m trying to find a way to set a new default ringtone by code from my Android activity. I have already downloaded the ringtone into a bytearray . 回答1: 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