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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:48:59+00:00 2026-06-18T01:48:59+00:00

1) this is my main activity package com.art.drumdrum; import android.app.Activity; import android.media.AudioManager; import android.media.SoundPool;

  • 0

1) this is my main activity

package com.art.drumdrum;

import android.app.Activity;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
SoundPool soundPool = null;
int kickId = 0;
int snareId = 0;

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

    Button kick = (Button) findViewById(R.id.kick);
    Button snare = (Button) findViewById(R.id.snare);
    kick.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction()==MotionEvent.ACTION_DOWN)
                soundPool.play(kickId, 1, 1, 0, 0, 1);
            return false;
        }
    });
    snare.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent Event) {
            if (Event.getAction()==MotionEvent.ACTION_DOWN)
                soundPool.play(snareId, 1, 1, 0, 0, 1);
            return false;
        }
    });


}

protected void onResume() {
    super.onResume();
    if (soundPool == null) {
        soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
        kickId = soundPool.load(this, R.raw.kick, 1);
        snareId = soundPool.load(this, R.raw.snare, 1);
    }
}

protected void onPause() {
    super.onPause();
    if (soundPool != null) {
        soundPool.release();
        soundPool = null;
    }
}

}

2) this is my main xml

<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/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button3"
    android:layout_below="@+id/button9"
    android:layout_marginLeft="20dp"
    android:text="@string/button" />

<Button
    android:id="@+id/button5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button2"
    android:layout_marginTop="86dp"
    android:layout_toLeftOf="@+id/button3"
    android:text="@string/button" />

<Button
    android:id="@+id/kick"
    style="@style/style"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="@string/kick" />

<Button
    android:id="@+id/snare"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button1"
    android:layout_marginTop="17dp"
    android:layout_toRightOf="@+id/kick"
    android:text="@string/snare" />

<Button
    android:id="@+id/button9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button3"
    android:layout_below="@+id/snare"
    android:text="@string/button" />

<Button
    android:id="@+id/button7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button5"
    android:layout_below="@+id/button2"
    android:layout_marginLeft="24dp"
    android:text="@string/button" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/snare"
    android:layout_alignParentTop="true"
    android:layout_marginTop="29dp"
    android:text="@string/button" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button5"
    android:layout_alignBottom="@+id/button5"
    android:layout_marginLeft="33dp"
    android:layout_toRightOf="@+id/snare"
    android:text="@string/button" />

<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button1"
    android:layout_alignBottom="@+id/button1"
    android:layout_alignLeft="@+id/button2"
    android:text="@string/button" />

</RelativeLayout>

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>

4) The sound works but i need to know how to take this and make it so i can hit 2 buttons at once and have them both out-put the sound, any ideas? thanks

  • 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-18T01:49:00+00:00Added an answer on June 18, 2026 at 1:49 am

    I don’t see anything wrong with the code. Are you sure your test device supports multi-touch?
    If I remember correctly, multi-touch was introduced in Froyo.

    edit:
    After looking at it again, I think I found the problem. Edit your code so this line

    if (Event.getAction()==MotionEvent.ACTION_DOWN)
    

    would read

    if (Event.getAction()==MotionEvent.ACTION_DOWN || Event.getAction()==MotionEvent.ACTION_POINTER_DOWN)
    
    • 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 java.util.Timer; import android.app.Activity; import android.media.MediaPlayer; 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;
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 created following activity package com.ali.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import
i have 2 spinner . this is my activity package com.example.belajarcombobox; import android.app.Activity; 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.