English 中文(简体)
Android ington
原标题:Android set ringtone failure
  • 时间:2012-01-15 13:19:12
  •  标签:
  • java
  • android

我尝试了以下法典,它 t了 r。 “......”的标志性条目说,我因此认为URI isnt正在被适当压缩? 我似乎可以指出,在我的法典中,我有错。

String filepath =Environment.getExternalStorageDirectory().toString()+"//media//audio//ringtones//bluemoon.mp3";
               File ringtoneFile = new File(filepath);
               ContentValues content = new ContentValues();
               content.put(MediaStore.MediaColumns.DATA,ringtoneFile.getAbsolutePath());
               content.put(MediaStore.MediaColumns.TITLE, "test");
               content.put(MediaStore.MediaColumns.SIZE, 215454);
               content.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg");
               content.put(MediaStore.Audio.Media.ARTIST, "artist");
               content.put(MediaStore.Audio.Media.DURATION, 230);
               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);
               Log.i("BOOM", "the absolute path of the file is :"+ringtoneFile.getAbsolutePath());
               Uri uri = MediaStore.Audio.Media.getContentUriForPath(
               ringtoneFile.getAbsolutePath());
               Uri newUri = getApplicationContext().getContentResolver().insert(uri, content);
               Uri ringtoneUri = newUri;
               Log.i("ff","the ringtone uri is :"+ringtoneUri);
               RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(),
               RingtoneManager.TYPE_RINGTONE,newUri);
最佳回答

其可能的数据对档案及其造成问题并不准确。 也许需要改变:

audio/mpeg to audio/mp3

www.un.org/chinese/sc/presidency.asp

Another thing you may want to fix is your ringtone file declaration statement, try changing it to match this:

File k = new File(path, "mysong.mp3");

此外,我感觉到你的道路也遭到破坏。

Environment.getExternalStorageDirectory().toString()+"//media//audio//ringtones//bluemoon.mp3"

<>strong>why with the two "/"?

应当(例如):

../sdcard/media/ringtone
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签