how to set ring tone

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

how to set ring tone

Postby ranjit0046 » Tue Dec 22, 2009 8:42 am

Hai ,

i am new to android can any body tell me how to set Ringtone using android .i need this functionality in my application please tell me its very urgent.

Thanks in advance
Ranjit..................................
ranjit0046
Developer
Developer
 
Posts: 47
Joined: Mon Dec 14, 2009 12:46 pm

Top

Setting Ringtone Query

Postby Maxood » Thu Dec 31, 2009 8:15 pm

This is what i am looking towards as well. 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?
Maxood

"Life is an endless journey to achieve perfection"
Maxood
Developer
Developer
 
Posts: 34
Joined: Sun Aug 02, 2009 1:37 pm
Location: Karachi, Pakistan

Postby ranjit0046 » Mon Jan 04, 2010 2:02 pm

public void setRingTone(Context context){

String filepath ="/sdcard/play2.mp3";
File ringtoneFile = new File(filepath);

ContentValues content = new ContentValues();
content.put(MediaStore.MediaColumns.DATA, ringtoneFile.getAbsolutePath());
content.put(MediaStore.MediaColumns.TITLE, "chinnu");
//content.put(MediaStore.MediaColumns.SIZE, 215454);
content.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
//content.put(MediaStore.Audio.Media.ARTIST, "Madonna");
//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);


//Insert it into the database
Log.i(TAG, "the absolute path of the file is :"+ringtoneFile.getAbsolutePath());
Uri uri = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile.getAbsolutePath());
Uri newUri = context.getContentResolver().insert(uri, content);
ringtoneUri = newUri;
Log.i(TAG,"the ringtone uri is :"+ringtoneUri);
RingtoneManager.setActualDefaultRingtoneUri(context,RingtoneManager.TYPE_RINGTONE,newUri);

}



use this class this will help u ....
ranjit0046
Developer
Developer
 
Posts: 47
Joined: Mon Dec 14, 2009 12:46 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 5 guests