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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:30:41+00:00 2026-05-24T22:30:41+00:00

Hey guys so when I run my app it goes to the main screen.

  • 0

Hey guys so when I run my app it goes to the main screen. From there I hit one of my two image buttons and a sound plays. The problem I’m having is that when i first push the button the sound is normal and loud and the button activity takes me to the next layout. If I go back to the main screen from the layout and try to hit the button again i can still hear the sound but just barely. It is almost inaudible sometimes. How would I get the sound to be consistent at all times? Thanks!

DragonFruitActivity.java

package com.Dragon_Fruit;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;

public class DragonFruitActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // ***BUTTON SOUND***//
        final MediaPlayer buttonSound = MediaPlayer.create(
                DragonFruitActivity.this, R.raw.button_click);

        ImageButton playbutton = (ImageButton) findViewById(R.id.playbutton);
        playbutton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                arg0.setBackgroundResource(R.drawable.playbuttonselected);
                // TODO Auto-generated method stub
                if(buttonSound.isPlaying()) {
                    buttonSound.stop();
                }

                try {
                    buttonSound.prepare();
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                buttonSound.start();

                startActivity(new Intent(DragonFruitActivity.this,
                        playbutton.class));
            }

        });
        ImageButton settingsbutton = (ImageButton) findViewById(R.id.settingsbutton);
        settingsbutton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                if(buttonSound.isPlaying()) {
                    buttonSound.stop();
                }

                try {
                    buttonSound.prepare();
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                buttonSound.start();

                startActivity(new Intent(DragonFruitActivity.this,
                        settingsbutton.class));
            }

        });
    }
}
  • 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-24T22:30:42+00:00Added an answer on May 24, 2026 at 10:30 pm

    How long is the sound? If is is really short (<250ms), I’ve seen an issue on some phones (Motorola Atrix) where the audio driver goes to sleep if no sounds have played in a while. In this case, really short sounds are either not played or are really quiet when you first play them because the audio driver is still waking up.

    My fix for this, which I’m not happy about at all, is to pad the front of the sound with a few milliseconds of low frequency sound (~20 Hz).

    You can verify if this is the issue you are seeing by playing your sound 2-3 times in quick succession when you press the button. If it is louder subsequent times, then this is probably the problem.

    You might also want to consider using a SoundPool for playing small sounds. It loads the sound into memory so that it can be played quicker.

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

Sidebar

Related Questions

Hey guys, here's my requirement: I have one central App which receives requests from
Hey guys i'm trying to figure out how to subtract one time from another
Hey guys, I am trying to run a proccess by submitting an AJAX form:
Hey guys I am getting this exception when trying to run the query Column
Hey Guys, here is my code for this, the only help i get from
Hey guys - I just wrote an app using c# and ready to deploy
Hey guys, I have a program that allows me to run queries against a
Hey guys, quick question, all I want to do is resize an image to
Hey guys. I'm trying to change the image in a container with what I
Hey guys i have been trying to download it from the below link http://www.enterprisedb.com/products-services-training/pgdownload

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.