How to get sound notification?

by Jenie » Sat, 27 Sep 2008 01:41:59 GMT


Sponsored Links
 In this code i don't get any sound for notification...Help me..
/***
        Copyright (c) 2008 CommonsWare, LLC

        Licensed under the Apache License, Version 2.0 (the "License"); you
may
        not use this file except in compliance with the License. You may
obtain
        a copy of the License at
                 http://www.apache.org/licenses/LICENSE-2.0 
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
        See the License for the specific language governing permissions and
        limitations under the License.
*/

package com.commonsware.android.notify;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Timer;
import java.util.TimerTask;

public class NotifyDemo extends Activity
{
        private static final int NOTIFY_ME_ID=1337;
        private Timer timer=new Timer();

        @Override
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                Button btn=(Button)findViewById(R.id.notify);

                btn.setOnClickListener(new View.OnClickListener()
                {
                        public void onClick(View view)
                        {
                                setDefault(Notification.DEFAULT_SOUND);
                                TimerTask task=new TimerTask()
                                {
                                        public void run()
                                        {
                                                notifyMe();
                                        }
                                };
                                timer.schedule(task, 5000);
                        }
                });

                btn=(Button)findViewById(R.id.cancel);

                btn.setOnClickListener(new View.OnClickListener()
                {
                        public void onClick(View view)
                        {
                                NotificationManager
mgr=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);

                                mgr.cancel(NOTIFY_ME_ID);
                        }
                });
        }

        protected void setDefault(int defaultSound) {
                // TODO Auto-generated method stub

        }

        private void notifyMe()
        {
                final NotificationManager
mgr=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
                Notification note=new Notification(R.drawable.red_ball,"Status
message!",System.currentTimeMillis());
                PendingIntent i=PendingIntent.getActivity(this, 0,new 
Intent(this,
NotifyMessage.class),0);

                note.setLatestEventInfo(this, "Notification Title","This is the
notification message", i);


                mgr.notify(NOTIFY_ME_ID, note);
        }
}

--~--~---------~--~----~------------~-------~--~----~



How to get sound notification?

by Mark Murphy » Sat, 27 Sep 2008 02:04:02 GMT


 > In this code i don't get any sound for notification...Help me..

Hey! This code looks familiar!


There is no sound associated with this Notification. You would probably
need to set the sound and audioStreamType public data members of the
Notification object to have it make a sound.

One of the ApiDemos probably demonstrates this, though the machine I'm
typing this on does not have the 1.0 SDK, so I can't cite any specifically
at this time.

--
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Mohon info

Dear rekan-rekan id android,
Apabila berkenan mohon info.
Apakah ada diantara rekan-rekan yg ingin menjual HTC evo 3D-nya??

Kalau boleh di infokan, ntar kami japri.
Terima kasih
Powered by Telkomsel BlackBerry

-- 
"

2. peculiar or undocumented behavior of ExifInterface?

I have been trying to use ExifInterface and am either doing something very 
wrong or my subject line is correct.

If I run the following code

                ExifInterface hoohaa;
                hoohaa = new ExifInterface(filename);
                hoohaa.saveAttributes();

on a photograph taken by the standard android Camera application, a whole bunch of exif fields previously defined have 
disappeared (as evidenced by inspection with Exiftool (Phil Harvey) and other such programs). I find this very peculiar.


On a much less important issue, if a photograph with a JPEG comment (NOT an 
exif UserComment) is the object of

                ExifInterface hoohaa;
                hoohaa = new ExifInterface(filename);
                String haahoo=hoohaa.getAttribute("UserComment");

the JPEG comment will be returned as if it were an exif UserComment. I find this friendly in a way, but unwarranted and 
undocumented...


Have I got this all wrong?

Bernard Higonnet

--

3. 2D acceleration (Froyo)

4. block telephone dan SMS di spica

5. Update facebook & twydroid

6. if i want to add overlay item to appear in map & also the gps point

7. help enabling NFS rootfs support