Hello,

I have an app in which I'm attempting to set the default ringtone of
the device to a resource. From my research I've seen that this can be
done with the RingtoneManager like this:

Uri mediaUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + getApplicationContext().getResources().getResourceName
(mediaId));
RingtoneManager.setActualDefaultRingtoneUri(getApplicationContext(),
RingtoneManager.TYPE_RINGTONE, mediaUri);
Log.i("ygg", "Ringtone Set to Resource: " + mediaUri.toString());
RingtoneManager.getRingtone(getApplicationContext(), mediaUri).play();

This would create a resource that would resember this:
android.resource://package.path/resource

In the end my resource looks like this: android.resource://
com.example.App.TestApp:raw/hello

Pulled directly from the log:
07-13 17:55:10.513: INFO/ygg(1252): Ringtone Set to Resource:
android.resource://com.example.App.TestApp:raw/hello

This is a simple file that says "hello".

I do NOT get an error in DDMS or the console windows nor on the app.
However, a couple lines later when I attempt to play the sound I get
the following errors output in DDMS:

07-13 17:55:10.533: ERROR/PlayerDriver(542): Command
PLAYER_SET_DATA_SOURCE completed with an error or info
PVMFErrNotSupported
07-13 17:55:10.543: ERROR/MediaPlayer(1252): error (1, -4)
07-13 17:55:10.543: ERROR/RingtoneManager(1252): Failed to open
ringtone android.resource://com.example.App.TestApp:raw/hello

I'm not manually coding the resource other than concatinating the
scheme and resource path, but I doubt this is the issue beause I've
also tried to use the Uri builder and it did not work. Here is how I
used it:

Uri mediaUri = new Uri.Builder().scheme
(ContentResolver.SCHEME_ANDROID_RESOURCE).appendEncodedPath
(getApplicationContext().getResources().getResourceName(mediaId)).build
();

What am I doing wrong? Any tips would be appreciated.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to