Hi guys I want to set the device ring-tone programmatically but the application crashes.
The code I used is this:
@Override
public void onClick(View v) {
Uri uri = Uri.parse("android.resource://"
+"com.ghzncl.barneystinsonsoundboard/"+R.raw.single]);
RingtoneManager.setActualDefaultRingtoneUri(
mContext, RingtoneManager.TYPE_NOTIFICATION, uri
);
// I set the data source of the mPlayer. I pass to
// the method the context and the uri of the resource.
try{
// I reset the mPlayer to its uninitialized state, in
// this way I don't need to stop the previews running quotes.
mPlayer.reset();
mPlayer.setDataSource(mContext,uri);
}catch(Exception e){
// Do Exception handling here...
}
try{
mPlayer.prepare();
}catch(Exception e){
// Do Exception handling here...
}
//The quotes start
mPlayer.start();
}
Anyone can please help me??