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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:45:45+00:00 2026-06-17T16:45:45+00:00

I’d like to change the ringer volume during ringing. Code below sets it during

  • 0

I’d like to change the ringer volume during ringing. Code below sets it during ringing (it is changed in system settings) but it doesn’t come to effect with actual ringing (only the next ring call will use new value). Can I force this changes to make them effect Immediately?

AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);    
audio.setStreamVolume(AudioManager.STREAM_RING, volume, AudioManager.FLAG_ALLOW_RINGER_MODES | AudioManager.FLAG_PLAY_SOUND);
  • 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-06-17T16:45:45+00:00Added an answer on June 17, 2026 at 4:45 pm

    After some research and tests I’ve found that volume change is possible only in very early stage of incomming call detection. It’s vital not to do much operations inside the onReceive() method.

    public class CallReceiver extends BroadcastReceiver   {
    
    private boolean isRinging = false;
    private boolean isInProgress = false;
    private Listener mListener = null;
    
    // interface declaration
     public interface Listener {
            public void onPhoneStateChange(boolean state);
        }
    
    // registration of listener
     public void registerListener (Listener listener) {
            mListener = listener;
        }
    
    
    @Override
    public void onReceive(Context context, Intent intent) {
    
    
            String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
    
            if(TelephonyManager.EXTRA_STATE_RINGING.equals(state))  {
                // do something while ringing BUT NOT TOO MUCH!
    
                isRinging = true;
    
                if (context instanceof StateChecker)
                      ((StateChecker) context).serviceDestroy();
                    Log.v("phone", "ringing");
    
            }
    
    
            else if(TelephonyManager.EXTRA_STATE_IDLE.equals(state))    {
                //do something when the call ends
                if (context instanceof StateChecker)
                      ((StateChecker) context).serviceStart();
                Log.v("phone", "idle");
                isRinging = false;
            }
    
    
            // sending notification to listener
            if(mListener != null)   {
                mListener.onPhoneStateChange(isRinging);
    
                Log.v("listener", "notified");
    
    
            }
    
    }
    
    }
    

    and some code from service:

    // listeners callbacks
    public void onPhoneStateChange(boolean state) {
    
        if (state) {
    
            if (!callInProgress)    {
    
           // Do the main task here
            callInProgress = true;
            serviceDestroy();
    
            }
    
        } else {
    
            callInProgress = false;
            serviceStart();
    
        }
    }
    

    ServiceStart:

     // starting service
    public void serviceStart()  {
    
        preferencesRead();
    
        //The intent to launch when the user clicks the expanded notification
        Intent intent = new Intent(this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);
    
    
    
        if(settings.getBoolean("hide_noti_icon", false))    {
         Notification noti = new NotificationCompat.Builder(this)
         .setContentTitle("Intelligent Ringer")
         .setContentText(getString(R.string.is_running))
         .setSmallIcon(R.drawable.invisible)
         .setContentIntent(pendIntent)
         .setPriority(Notification.PRIORITY_MIN)
         .build();
    
         startForeground(12345, noti); 
    
    
        } else  {
    
             Notification noti = new NotificationCompat.Builder(this)
             .setContentTitle("Intelligent Ringer")
             .setContentText(getString(R.string.is_running))
             .setSmallIcon(R.drawable.ic_launcher)
             .setContentIntent(pendIntent)
             .setPriority(Notification.PRIORITY_MIN)
             .build();
    
             startForeground(12345, noti); 
        }
    
    
        Log.v("service", "started");
        // registering listener for CallReceiver
        if(isCRRegistered)  {
            unregisterReceiver(mCallReceiver);
            isCRRegistered = false;
        }
    
        if(!isCRRegistered) {
    
         IntentFilter filter2 = new IntentFilter("android.intent.action.PHONE_STATE");
         filter2.addAction("android.intent.action.PHONE_STATE");
         CallReceiver mCallReceiver = new CallReceiver();
         this.mCallReceiver = mCallReceiver;
           registerReceiver(mCallReceiver, filter2);
           mCallReceiver.registerListener(this);
           isCRRegistered = true;
        }
    
        if(isScreenRegistered)  {
            unregisterReceiver(mReceiver);
            isScreenRegistered = false;
        }
    
    
    
        if(!isPositionRegistered && proximityOn)    {
    
            Position mPosition = new Position(this.getApplicationContext());
            mPosition.registerListener(this);
            mPosition.isInPocket();
            this.mPosition = mPosition;
            mPosition.register();
    
            isPositionRegistered = true;
    }
    
        if(!isScreenRegistered) {
            IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
            filter.addAction(Intent.ACTION_SCREEN_OFF);
            ScreenReceiver mReceiver = new ScreenReceiver();
            registerReceiver(mReceiver, filter);
            this.mReceiver = mReceiver;
    
            mReceiver.registerListener(this);
    
            isScreenRegistered = true;
        }
    
    
    }
    

    Servicedestroy()

    // stopping service
    public void serviceDestroy()    {
    
    
        if (this.mPosition != null) {
        this.mPosition.unregister();
        }
    
        Log.v("service", "Destroyed");
    
        if(isScreenRegistered)  {
            unregisterReceiver(mReceiver);
            isScreenRegistered = false;
        }
    
    }
    

    OnDestroy()

    public void onDestroy () {
        serviceDestroy();
    
    
        if(isCRRegistered)  {
    
            unregisterReceiver(mCallReceiver);
            isCRRegistered = false;
    
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with like below codes: Table: Accounts id | username |
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.