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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:57:06+00:00 2026-06-18T06:57:06+00:00

1)This is my main activity package com.art.drumdrum; import java.util.Timer; import android.app.Activity; import android.media.MediaPlayer; import

  • 0

1)This is my main activity

package com.art.drumdrum;

import java.util.Timer;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

Timer time;
MainActivity p;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final MediaPlayer mpButtonClick = MediaPlayer.create(this, R.raw.kick);

    Button kick = (Button) findViewById(R.id.kick);
    kick.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            mpButtonClick.start();
        }
    });

}

}

2) this is my xml manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.art.drumdrum"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.art.drumdrum.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

</manifest>

3)this is my main layout xml ( mainly look at button id “kick”)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".MainActivity" >

<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button6"
    android:layout_alignBottom="@+id/button6"
    android:layout_marginLeft="39dp"
    android:layout_toRightOf="@+id/button6"
    android:text="Button" />

<Button
    android:id="@+id/button6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button8"
    android:layout_marginTop="15dp"
    android:layout_toRightOf="@+id/button8"
    android:text="Button" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button7"
    android:layout_marginTop="48dp"
    android:layout_toRightOf="@+id/button6"
    android:text="Button" />

<Button
    android:id="@+id/button7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button2"
    android:layout_below="@+id/button5"
    android:layout_marginTop="18dp"
    android:text="Button" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button3"
    android:layout_below="@+id/button1"
    android:layout_marginLeft="14dp"
    android:text="Button" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/button6"
    android:layout_marginRight="22dp"
    android:layout_marginTop="22dp"
    android:text="Button" />

<Button
    android:id="@+id/button9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button6"
    android:layout_marginTop="22dp"
    android:layout_toLeftOf="@+id/button7"
    android:text="Button" />

<Button
    android:id="@+id/kick"
    style="@style/style"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignBaseline="@+id/button3"
    android:layout_alignBottom="@+id/button3"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="25dp"
    android:text="kick" />

<Button
    android:id="@+id/button5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button6"
    android:layout_alignTop="@+id/button2"
    android:layout_marginTop="33dp"
    android:text="Button" />

</RelativeLayout>

4)Just want each button to have a sound and then be able to keep hitting them and the sounds overlap, right now it waits for the sound to end before it plays the next, even if im just hitting the same key

  • 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-18T06:57:07+00:00Added an answer on June 18, 2026 at 6:57 am

    It seems like you only have one MediaPlayer object. If that is true, then it is one reason why you can only play one sample at time. Try using multiple MediaPlayer objects Perhaps one for each button?

    I am still not certain if that will work though, it might be a limitation of the MediaPlayer class itself. In this case you’ll want to use SoundPool instead, and make sure to set the max streams to something > 1.

    It would look something like this:

    sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
    int streamID = sp.load(this, R.raw.sound, 1);
    //....
    sp.play(streamID, 1, 1, 1, 0, 1);
    

    the 5 is this example is the max streams value, so if you need more than 5 streams at once change it.

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

Sidebar

Related Questions

1) this is my main activity package com.art.drumdrum; import android.app.Activity; import android.media.AudioManager; import android.media.SoundPool;
1)this is my Main Activity : package com.art.drumdrum; import android.app.Activity; import android.media.AudioManager; import android.media.SoundPool;
this is my MainActivity: package com.FBupdater; import java.io.IOException; import java.net.MalformedURLException; import android.app.Activity; import android.os.Bundle;
This is the code from my MainActivity: package com.simple.flashlight; import android.os.Bundle; import android.app.Activity; import
i have 2 spinner . this is my activity package com.example.belajarcombobox; import android.app.Activity; import
package com.ebonybutler.cexample3; import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener;
I have created following activity package com.ali.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import
i have the following piece of code : package com.example.task; import java.util.List; import android.os.Bundle;
I have a GridView like this( main.xml ): <?xml version=1.0 encoding=utf-8?> <GridView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/gridView1
i am having my manifest file like this <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.basic.adwhrilsample android:versionCode=1 android:versionName=1.0 >

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.