Thursday, June 23, 2011

[android-developers] Re: Intercept SMS, disable notification sound

This works just fine. Called within the onRecieve() of my
SMSReceiver.

I'm guessing the next step to playing your own sound effect is to just
play a sound on a different stream on onReceive() as well.


On Jun 23, 12:01 am, rich friedel <rich.frie...@gmail.com> wrote:
> Just get the content of the SMS and do a simple if/else check. If it is your
> text then disable the sound using AudioManager something like this...
>
>     private static AudioManager audioManager;
>
>     @Override
>     public void onCreate() {
>         super.onCreate();
>         audioManager = (AudioManager)this.getSystemService(AUDIO_SERVICE);
>         ...
>     }
>     private void disableNotifySound(String pTextToCheck) {
>         String _theString = "...something...";
>         if(pTextToCheck == _theString) {
>             audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION,
> false);
>         } else {
>             audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION,
> true);
>         }
>     }

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment