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)
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. ProgressDialog went back to the first view called it when dismiss()

Hi, I have a weird problem on progress dialog:

I have 2 views: Login View and say, Display View.

In Login View, when I click the 'Login' button, a progress dialog is
created (new ProgressDialog(...)), shown and stored in a variable
'mProgressDialog'. After login, the dialog is dismissed and some
information are displayed in Display View (Login View hides). Now I
want to display another progress dialog when 'Update' button is
clicked and when the update is done, dismiss the dialog and display
new information. So I use:

mProgressDialog = new ProgressDialog(...);

to create a new progress dialog with new title and message. Show.

Now the weird thing happens when the new dialog dismisses. The program
flashes the Display View for a blink and then shows the Login View....

I tried to change the view etc. but same problem happens over and over
again. So I am thinking it might because one activity can only be
assigned to ONE progress dialog and no matter how you re-create it you
still get the same progress dialog. And the dialog is linked to a
certain view which will be shown automatically when the dialog

Please tell me I am wrong...


2. Trouble with getting proximity alerts


SDK: 1.6
Firmware Version: 1.5

I am trying to get an alert when I get to my home. But, it looks like I am
not receiving the message. Googled around quite a bit, but to no avail. I am
able to get the LocationListener to display my current location. But,
proximityAlerts are not working. The problem might be with the setting up
and receiving the broadcast messages.

Any help is appreciated. Following  is my code.

My Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon"
android:label="@string/app_name" android:debuggable="true">

    <uses-library android:name="" />

        <activity android:name=".MapsActivity"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

     <*receiver *android:name=".ProximityIntentReceiver">
        <action android:name="android.intent.action.PROXIMITY_ALERT" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"

    <uses-permission android:name="android.permission.COARSE_FINE_LOCATION"

    <uses-sdk android:minSdkVersion="3" />



public class MapsActivity extends MapActivity {

    MapController mc;
    GeoPoint home = null, school = null, curLoc = null;
    MapOverlay mapOverlay;
    MapView mapView;
    protected static final String PROXIMITY_ALERT = new
    protected final IntentFilter proximitylocationIntentFilter = new
    Intent intent = new Intent(PROXIMITY_ALERT);

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        //get the underlying mapView
        mapView = (MapView) findViewById(;

       //set some mapView properties
       //set home address

        //now play with the location
        LocationManager lm = (LocationManager)

        //Send current location messages to the listener every second.
        CurrentLocationListener listener = new CurrentLocationListener();
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1,

        //Get a message when we get near home...
        PendingIntent proximityIntent =
PendingIntent.getBroadcast(getApplicationContext(),0, intent, 0);
        lm.addProximityAlert(home.getLatitudeE6(), home.getLongitudeE6(),
50, 1000000, proximityIntent);

       * //the returned value "check" is always null.* I know the new object
ProxmityIntentReceiver object is being created.
        Intent check = registerReceiver(new ProximityIntentReceiver(),

    protected boolean isRouteDisplayed() {
        return false;

    public void setHomeAddress(MapView mapView)
        //snip set the home address co-ordinates and call MapOverlay to


private class CurrentLocationListener implements LocationListener

    public void onLocationChanged(Location location) {

    //get the current location and display that in the map.
    curLoc = new GeoPoint(
                (int) (location.getLatitude() * 1E6),
                (int) (location.getLongitude() * 1E6));

        //---Add a location marker---
        mapOverlay = new MapOverlay(curLoc);
        List<Overlay> listOfOverlays = mapView.getOverlays();
  //snip other overridden methods

} //end of MapsActivity cla

Below is the code to recieve the proximity message which never gets called.


public class ProximityIntentReceiver extends BroadcastReceiver {

    public void onReceive (Context context, Intent intent) {

        Log.i("ProximityReceiver","Here in onRecieve");



3. Device orientation - mapping device Y to screen Y

4. Android NDK Socket programming

5. java.lang.OutOfMemoryError after orientation changed

6. Broken Emulator after new update?

7. Does DexClassLoader works correctly?