Notification to play sound

by droozen » Fri, 13 Mar 2009 01:10:04 GMT


Sponsored Links
 So I've set up my app to have a repeating alarm, daily, as the user
decides, using AlarmManager. I want the user to select a ringtone for
it. This works fine, too. I store the string of the Uri they selected
in a preference to pull it back when my alarm gets run. To pull it
back, I do this:

NotificationManager notifManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification(-notification stuff-);
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String reminderSound = settings.getString(getString
(R.string.RingtoneReminder), null);
if(reminderSound != null){
        notif.sound = Uri.parse(reminderSound);
}

So I set the Notification's sound field to the Uri of my notification.
Later, when I call the notifManager.notify(rowId, notif), the
notification still pops up, but the sound doesn't play.

How do I get the sound to play?
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. File upload in background: thread/service/AIDL...?

Nothing, really. I just want to upload a file in the background, with
an icon in the status bar, and update the icon when the upload is
complete.

I might possibly want to call the main application back again when the
upload is complete or if there is a problem, but I don't expect to use
the Service for anything else.

Does that sound OK? So the most communication I would need is (i) pass
a filename to the Service, and (ii) go back to the main application
once the upload is complete.

Anna






-- 

2. File upload in background: thread/service/AIDL...?



In which case, do the following:

Step #1: Implement your Service as a subclass of IntentService.
IntentService handles the whole background thread thing for you, so you
will not need an AsyncTask.

Step #2: Put your file-upload logic in onHandleIntent() in your
IntentService subclass.

Step #3: When you have something to upload, create an Intent that
identifies the service (e.g., new Intent(this, MyService.class);) and
put a string extra on it (via putExtra()) that contains the thing to upload.

Step #4: Call startService() with the Intent from Step #3.

Step #5: In onHandleIntent(), you are passed the Intent, so you can call
getStringExtra() to get the value and use it.

Step #6: There is no step #6. Your service will automatically shut down
when there is nothing more to upload, and it will be restarted
automatically if another upload is required.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 2.0 Available!

-- 

3. Variable in getResources().getStringArray

4. Invalid statement in fillWindow()

5. File upload in background: thread/service/AIDL...?

6. how to fully "delete"/finish an activity

7. style problem in 1.5