ringtone

How set duration of the ringtone's play

半城伤御伤魂 提交于 2019-12-12 04:37:21
问题 My app play ringtone. My code: RingtoneManager.getRingtone( context, RingtoneManager.getDefaultUri( RingtoneManager.TYPE_NOTIFICATION)).play(); Ringtone play very well. But if ringtone is long I need cut the first N milliseconds from it. How get full duration of this ringtone? How set maximum duration in milliseconds of this ringtone? 回答1: Just put the RingTone in mediaPlayer for eg Mediaplayer mp =new MediaPlayer(); uri = RingtoneManager.getDefaultUri( RingtoneManager.TYPE_NOTIFICATION)) mp

Make soundclip in a listView selectable as (notification) ringtone?

不想你离开。 提交于 2019-12-11 23:18:00
问题 I've got a list of tones which I've made, I've managed to get them into a list but now I'm faced with the challenge of allowing the user to "touch and hold" to assign as a notification tone. Here's the code from MainActivity.java: import java.util.ArrayList; import android.app.ListActivity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.MenuInflater; import android.view.View;

java.lang.IllegalStateException in MediaPlayer.setDataSource, using Ringtone class

前提是你 提交于 2019-12-11 13:57:11
问题 I had a crash reported by an user (Samsung Galaxy S5, Android 4.4) and I do not understand what is happening. It seems imporbable but maybe some people have encountered the same problem, or similar. Here is the trace: java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java

The method setActualDefaultRingtoneUri(Context, int, Uri) in the type RingtoneManager is not applicable for the arguments OnItemClickListener

不羁岁月 提交于 2019-12-11 11:44:40
问题 I am making android application and I want when I click on list view item to find ID of clicked item, get resources and set that file as ringtone.However I get this error : The method setActualDefaultRingtoneUri(Context, int, Uri) in the type RingtoneManager is not applicable for the arguments ( new AdapterView.OnItemClickListener ) How can I fix this? listv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position,

How to play a specifc audio file from Android in build rintone list?

不问归期 提交于 2019-12-11 06:45:48
问题 I need to know is it possible to play a particular audio file from android in-built ringtone files. For example assume Tone_23 is in android ringtone list, now i need to play this particular tone, when i click a button. I searched in Google i got a guidance how to call/show RingtonePicker Activity (The entire Ringtone list will be displayed). If this possible means, kindly share your thoughts. Thanks in advance. 回答1: You can try some thing like this : /** * Play ring tone. * * @param

Programatically Set Custom Notification Ringtone (Choose from AUDIO files in Mobile) for App

℡╲_俬逩灬. 提交于 2019-12-11 04:09:52
问题 I want to list all the available AUDIO (.mp3) files in Mobile device. User can select any Audio file from list and can set as a Notification Tone for this App. I worked out many sources and none of them satisfiable. Thank you. 回答1: First get all the available mp3 files and retreive their names using the code below do whatever u want with the retreived data for eg u can set up to a list view or showing them in a dialog etc. String extPath = getSecondaryStorage(); if (extPath != null) { mySongs

ContentResolver.insert returns null

≡放荡痞女 提交于 2019-12-10 18:02:22
问题 I sometimes have a problem when setting sounds as ringtones / notifications from inside an activity: ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, source); values.put(MediaStore.MediaColumns.TITLE, "abc"); values.put(MediaStore.MediaColumns.SIZE, new File(source).length()); values.put(MediaStore.MediaColumns.MIME_TYPE, mime); values.put(MediaStore.Audio.Media.ARTIST, "xyz"); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore

How to set custom Alarm tone in android

旧城冷巷雨未停 提交于 2019-12-10 17:57:05
问题 I need to set custom alarm tone in my App. Could anyone please just tell me how to set custom ringtone or Mp3 as an alarm ? Any kind of help will be appreciated. 回答1: Here is also a solution for this problem setting audio file as Ringtone Best, Shahzad Majeed 回答2: You can use audio player to play your mp3.But here is a better alarm app which fulfills your requirements. http://code.google.com/p/kraigsandroid/source/browse/#git%2Fandroid%2Falarmclock%2Fsrc%2Fcom%2Fangrydoughnuts%2Fandroid

setting raw resource as a ringtone

主宰稳场 提交于 2019-12-10 14:48:06
问题 I have read these 2 posts link1 and this one link2 but code does not seem to work for me. Here is my code: File newSoundFile = new File("/sdcard/media/ringtone", "myringtone.oog"); Uri mUri = Uri.parse("android.resource://com.pack.android.myapp/R.raw.song1"); ContentResolver mCr = Main.this.getContentResolver(); AssetFileDescriptor soundFile; try { soundFile= mCr.openAssetFileDescriptor(mUri, "r"); } catch (FileNotFoundException e) { soundFile=null; } try { byte[] readData = new byte[1024];

Setting sound for notification

霸气de小男生 提交于 2019-12-10 09:27:29
问题 How can I set sound for notification for my android application. In my application notification will be shown after 30 seconds. I want to give options for this alerts such as silent mode, vibration mode and an option to select from the available tones from the device. I am using the preference screen to show the settings menu. I want to to set the notification ring type application specific. Is there any way to establish this.. 回答1: http://developer.android.com/reference/android/app