Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old December 29th, 2009, 03:39 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2009
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Refreshing Ringtone List

I am attempting to allow a user to save raw audio from my app to their SD card. Then in turn select that audio as a ring tone.

My code:
------------------------------------------------------
InputStream fIn = getBaseContext().getResources().openRawResource(cl ipID);
int size = fIn.available();
byte[] buffer = new byte[size];
fIn.read(buffer);
fIn.close();

File rtNew = new File(
"/sdcard/XYZ/Ringtones/"
+ ((Button) findViewById(buttonID)).getText()
+ ".ogg");

FileOutputStream rtFOS = new FileOutputStream(rtNew);
rtFOS.write(buffer);
rtFOS.flush();
rtFOS.close();
-------------------------------------------------------
buttonID is the int from R.id.buttonX and clipID is R.raw.clipX. The directory /sdcard/XYZ/Ringtones has been created previously in the application. I can confirm that the directory and the file are created using ASTRO.

I've tried several variations on this code(which is why rtNew is a separate object). Including using /sdcard/ringtones and using all variations of case sensitive directories and file names.

No matter what I try I cannot get the audio clip to appear in the "Settings->Sound & display->Phone ringtone" list.

Here's the EXCEPTION:
-I allow my app to create the directories and the file
-confirm with ASTRO that they've been created
-confirm that it IS NOT in the ring tones list
-rename the file with ASTRO without changing the file name
-then the file appears in the ring tones list

This exception adds the file to the ringtones list even in a directory /sdcard/XYZ/ringtones. I've also tried rtNew.renameTo after writing the file. This did not work either.

Has anyone experienced this or have a solution?

Thanks.

Advertisements
itzdiceman is offline  
Reply With Quote
sponsored links
Old December 29th, 2009, 05:34 PM   #2 (permalink)
Member
 
Join Date: Nov 2009
Posts: 103
 
Device(s): Droid
Carrier: Not Provided

Thanks: 0
Thanked 4 Times in 4 Posts
Default

Try this as a test.

Save the file to your expected directory... /sdcard/xyz/ringtones or whatever.

Plug the phone into your computer. And mount the sdcard. Browse ... then re-mount the sdcard.

See if your audio file is now within the ringtones list?

Unless your telling the lower layers about the new file, the android api has no idea you just created a new media file. You might need to tell the media provider that you have a new file for it to include.

Try this portion of the api

Its just a guess
KeithG is offline  
Reply With Quote
Old December 30th, 2009, 08:32 AM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Dec 2009
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Awesome.

Thanks a lot. MediaScanner worked perfectly.
itzdiceman is offline  
Reply With Quote
Old December 31st, 2009, 04:54 AM   #4 (permalink)
New Member
 
Join Date: Dec 2009
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Possible on android which version

It is possible on android which version?. Can u help me.
ajaypradhan is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:01 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.