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

  • Home
  • SEARCH
  • 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 8060037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:51:27+00:00 2026-06-05T09:51:27+00:00

i was struggling for this for one day and the issue is still there.

  • 0

i was struggling for this for one day and the issue is still there.

I have 2 function in my activity which is mute and unmute as below:

private void mute() {
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

public void unmute() {
      AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
      am.setStreamMute(AudioManager.STREAM_MUSIC, false);
    }

Within the activity itself this 2 function work fine. However, when it is muted in the first activity and I want to unmute it for the next activity, the activity remain mute. I am wondering why? Could anyone please give me some advice? Thanks a lot!

Updated:
This is part of the code:

 ImagePlay.setOnClickListener(new View.OnClickListener() 
                        {
                            // Perform button logic
                            @Override
                            public void onClick(View v)
                            {
                                unmute();
                                onResume();
                                Speaker = (ImageView)findViewById(R.id.ImageSpeaker);    
                                Speaker.setImageBitmap(mAudioImageArray[0]);
                                closeDialog.dismiss();
                                play(DOSParseActivity.this,introAudioPath);
                                isMute = false;
                            }
                        });

                        ImageMute.setOnClickListener(new View.OnClickListener() 
                        {
                            // Perform button logic
                            @Override
                            public void onClick(View v)
                            {
                                Speaker = (ImageView)findViewById(R.id.ImageSpeaker);    
                                Speaker.setImageBitmap(mAudioImageArray[1]);
                                closeDialog.dismiss();
                                mute();
                                onPause();
                                isMute = true;
                            }
                        });

                        ImageStop.setOnClickListener(new View.OnClickListener() 
                        {
                            // Perform button logic
                            @Override
                            public void onClick(View v)
                            {
                                Speaker = (ImageView)findViewById(R.id.ImageSpeaker);    
                                Speaker.setImageBitmap(mAudioImageArray[2]);
                                closeDialog.dismiss();
                                stop();
                                isMute = false;
                            }
                        });

            /////////////////////////////////////Navigation Button////////////////////////////
                        imageNext = new ImageButton(this);
                        InputStream toNextInput = mngr.open(toNextImage);
                        final Bitmap bitmaptoNext = BitmapFactory.decodeStream(toNextInput);
                        imageNext = (ImageButton)findViewById(R.id.ImageNext);
                        imageNext.setImageBitmap(bitmaptoNext);
                        imageNext.setOnClickListener(new View.OnClickListener() 
                        {
                            public void onClick(View v) 
                            {
                                stop();
                                Bitmap resizedBitmap = Bitmap.createScaledBitmap(bitmaptoNext, 54, 54, true);
                                imageNext.setImageBitmap(resizedBitmap);

                                Intent intent = new Intent(v.getContext(), Characteristic.class);

                                intent.putExtra("checkMute", "mute" );
                                intent.putExtra("languageSelection", languageSelected );
                                startActivity(intent);

                            }
                        });

private void play(Context context, String file) {

    try {
        if (IntroPlayer == null) 
        {
            this.IntroPlayer = new MediaPlayer();           
        }
        else
        {
            IntroPlayer.stop();
            IntroPlayer.reset();
        }

        AssetFileDescriptor afd = context.getAssets().openFd(file);
        IntroPlayer.setDataSource(
                afd.getFileDescriptor(),
                afd.getStartOffset(),
                afd.getLength()
            );
        afd.close();
        IntroPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        IntroPlayer.setOnPreparedListener(this);
        IntroPlayer.prepareAsync();

    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    }


 @Override
     public void onSwipe(int direction) {
      Intent intent = new Intent();

  switch (direction) {
  case SimpleGestureFilter.SWIPE_RIGHT :
      if (IntroPlayer != null) 
        {
             stop();  
        }
      intent.setClass(this,LocalizationAppActivity.class);
         intent.putExtra("languageSelection", languageSelected );
         break;

  case SimpleGestureFilter.SWIPE_LEFT :  
    if (IntroPlayer != null) 
    {
        stop();   
    }
      intent.setClass(this,Characteristic.class);
      intent.putExtra("languageSelection", languageSelected );

      break;

  }
   startActivity(intent);

 }

@Override
public void onPrepared(MediaPlayer mp) {
    // TODO Auto-generated method stub
     mp.start();
}

private void stop() {
    IntroPlayer.stop();
}

private void mute() {
    am.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

public void unmute() {
      int maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
      am.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
      am.setStreamMute(AudioManager.STREAM_MUSIC, false);
    }

@Override
public void onDestroy() {
     super.onDestroy();
     stop();


}
  • 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-05T09:51:29+00:00Added an answer on June 5, 2026 at 9:51 am

    Take public static AudioManager am ; in one Global.java and u can use and set property try it will be work for u.

    private void mute() {
        Global.am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        am.setStreamMute(AudioManager.STREAM_MUSIC, true);
    }
    
    public void unmute() {
          Global.am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
          am.setStreamMute(AudioManager.STREAM_MUSIC, false);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im struggling with this one. I have a list of items and on a
Hi everyone i am struggling on this one, have google searched this one hard
I am really struggling with this one. I have Google'd this and tried most
Hoo-boy I've been struggling with this one all day. The redirect from the subdomains
Quite new to Linq, and I'm struggling with this one. Basically I have a
Really struggling with this one: I have an existing foreach, containing an if loop
I've been struggling with this all day long! In the GemFile, I have: group
I have been struggling with this for the entire day now, I hope somebody
Struggling with this one. I have set up a basic email/enquiry form for a
I've been struggling with this one for a couple of days now. My current

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.