Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:21:33+00:00 2026-05-15T19:21:33+00:00

I have an application that creates a notification with sound when a specific text

  • 0

I have an application that creates a notification with sound when a specific text comes in. To do this, I detect the current ringerMode, change the ringerMode to normal, play the sound, and then quickly return the ringer back to its original setting. Here is the code:

public static AudioManager audio;

    audio = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

ringMode = audio.getRingerMode();
        if (ringMode < 2)
        //Checks to see if the phones ringer is set to silent, or vibrate
            audio.setRingerMode(2);

        //vibrates phone in a pattern
        long[] pattern = {0, 25};
        //long[] pattern = {0, 1000, 100, 100, 100, 100, 100, 1000}; 
        v.vibrate(pattern, -1); 
        final int HELLO_ID = 1;
        mNotificationManager.notify(HELLO_ID, notification);

        //delays return back to original volume so notification can be heard
        Handler handler = new Handler();  
        handler.postDelayed(new Runnable() {  
             public void run() {  
                 audio.setRingerMode(ringMode); 
             }  
        }, 4000);
        }

This works completely fine in an activity, but not in this notification service, and is currently placed in the onStart method.
uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS” has also been added to the manifest. Any ideas?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:21:33+00:00Added an answer on May 15, 2026 at 7:21 pm

    Not really the solution to that problem, but I realized that there was a Notification volume stream I should have been adjusting. With pretty much exact same code, the Notify class now works properly.

    if (startSound)
            {   
                //This sound plays using the ringer volume
                //notification.sound = Uri.parse("android.resource://itp.uts.program/" + R.raw.pager);
    
                //Sets ringer temporarily to active, so notification is heard
                audio.setStreamVolume(5, 3, 0); 
    
                //vibrates phone in a pattern
                long[] pattern = {0, 25};
                //long[] pattern = {0, 1000, 100, 100, 100, 100, 100, 1000}; 
                v.vibrate(pattern, -1); 
            }
            //Creates the notification
            mNotificationManager.notify(HELLO_ID, notification);
    
            if (startSound)
            {
            //delays return back to original volume so notification can be heard
            Handler handler = new Handler();  
            handler.postDelayed(new Runnable() {  
                 public void run() {  
                     audio.setStreamVolume(5, streamVolume, 0); 
                 }  
            }, 7000);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application that creates notifications, using the following code: // notification
I have a program that creates a notification if the application is not running.
I have an application that creates invalid Directories... e.g. c:\Program Files\somedirectory. - the period
I have created an application that creates bar graph based on inputs read from
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a .Net application that dynamically creates a small HTML page and pops
Today we have a windows application that, using an OCX, creates a web page
I have created an application that uses settings.settings to store some user specific settings
I have an application that starts a timer and an ongoing notification. Whenever I
I have an application that needs updating constantly. I would like to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.