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 7691041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:32:05+00:00 2026-05-31T20:32:05+00:00

I have a task – change the ringer volume immediately when phone ringing. For

  • 0

I have a task – change the ringer volume immediately when phone ringing. For example:
After detecting, that there is incoming call I need to set ringer volume to 0 (mute) and vibrator also should be disabled (if it not disabled already). Then there is delay when I need to perform another code (startComputing();). After that ringer volume should be changed to certain value (f.e.7) and vibrator should be activated. Here is my code:

    public class IncomingCallReceiver extends BroadcastReceiver {
        private AudioManager amanager;
        public void onReceive(Context context, Intent intent) {
            if(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                amanager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
                amanager.setRingerMode(0x00000000); // no sound and no vibration            
                startComputing();
                amanager.setRingerMode(0x00000002); // normal
                amanager.setStreamVolume(AudioManager.STREAM_RING, 7,
                        AudioManager.FLAG_SHOW_UI
                                + AudioManager.FLAG_PLAY_SOUND);
            }

        }
        private void startComputing() {
            try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }       
        }

}

1)The main problem is that after this: amanager.setStreamVolume(AudioManager.STREAM_RING, 7, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
ringer does not ring at all, only toast message appears that sound level changed but phone does not play any sound. How this can be changed?
2)Also there is problem that amanager.setRingerMode(0x00000000); does not change Volume and vibration immediately but just in about half a sec.
Thank You in Advance.
Jacob

  • 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-31T20:32:06+00:00Added an answer on May 31, 2026 at 8:32 pm

    I don’t think there is anything you can do to overcome the 1/2 sec delay before you mute the ringer. Sometimes it works (ie very short or no delay), sometimes you will hear the ringer for a short period of time.

    I think the problem you are having is with the flags passed to setStreamVolume.

    Try this:

    amanager.setStreamVolume(AudioManager.STREAM_RING, 7,
        AudioManager.FLAG_SHOW_UI|AudioManager.FLAG_PLAY_SOUND);
    

    You should be using the bitwise inclusive or (|), and not simple addition (+).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have task which takes a parameter and has three modes of results Example
I have task involving reading SAS .xpt files using .NET. For that I'm using
I have a task I need to perform, do_stuff(opts) , that will take ~1s
I have task to give in my application possibility to open document that is
I have: Task Entity that holds a foreignkey to a Project Entity. In the
My Task have multiple relateddocId for example RelatedDoc=3,5,2,6, now i need to add multiplevalue
I have task schedule for backup directory list of wwwroot. For that I have
I have a Task object that has a collection of Label objects ... in
I have a task that is not important ; it should be run once
Say that I have two resources, Project and Task. A Project can have many

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.