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

The Archive Base Latest Questions

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

I have created two classes, actually both of them extends Activity. What I am

  • 0

I have created two classes, actually both of them extends Activity. What I am trying to do is to call a method from the second class.

What I am trying to do is calling the method from second class then implemented in first class, unfortunately I did not have success in that.

I need your help to solve this problem. Thank you

My first class:

package com.math4kids;

import android.app.Activity;
import android.os.Bundle;

public class testing002 extends Activity {

private Sounds myotherclass;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.numeracy);

    myotherclass.Randomsoundforrightanswer();

}

}

The second class:

package com.math4kids;

import java.util.Random;

import android.app.Activity;
import android.content.Context;
import android.media.MediaPlayer;

public class Sounds extends Activity {

MediaPlayer cool, good, perfect, sweet, excellent, goodthinking, greatjob,
        notbad, thatstheway, youdidit, yes, again, wrong, sorry,
        sundfornum01, sundfornum02;
public Random random = new Random();

public Sounds(Context context){
    super.getApplicationContext();
}

public void Randomsoundforrightanswer() {
    cool = MediaPlayer.create(this, R.raw.cool);
    good = MediaPlayer.create(this, R.raw.good);
    perfect = MediaPlayer.create(this, R.raw.perfect);
    sweet = MediaPlayer.create(this, R.raw.sweet);
    excellent = MediaPlayer.create(this, R.raw.excellent);
    goodthinking = MediaPlayer.create(this, R.raw.goodthinking);
    greatjob = MediaPlayer.create(this, R.raw.greatjob);
    notbad = MediaPlayer.create(this, R.raw.notbad);
    thatstheway = MediaPlayer.create(this, R.raw.thatstheway);
    youdidit = MediaPlayer.create(this, R.raw.youdidit);
    yes = MediaPlayer.create(this, R.raw.yes);

    switch (random.nextInt(11)) {

    case 0:
        cool.start();
        break;
    case 1:
        good.start();
        break;
    case 2:
        perfect.start();
        break;
    case 3:
        sweet.start();
        break;
    case 4:
        excellent.start();
        break;
    case 5:
        goodthinking.start();
        break;
    case 6:
        greatjob.start();
        break;
    case 7:
        notbad.start();
        break;
    case 8:
        thatstheway.start();
        break;
    case 9:
        youdidit.start();
        break;
    case 10:
        yes.start();
        break;

    }

}


}
  • 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:22:10+00:00Added an answer on June 18, 2026 at 6:22 am

    Make a simple normal java file then define these methods in that class.

    import java.util.Random;
    import android.media.MediaPlayer;
    
    public class Sounds {
    
        Context context;
        MediaPlayer cool, good, perfect, sweet, excellent, goodthinking, greatjob,
            notbad, thatstheway, youdidit, yes, again, wrong, sorry,
            sundfornum01, sundfornum02;
        public Random random = new Random();
    
        public Sounds(Context context){
            this.context = context;
        }
    
        public void Randomsoundforrightanswer() {
            cool = MediaPlayer.create(context, R.raw.cool);
            good = MediaPlayer.create(context, R.raw.good);
            perfect = MediaPlayer.create(context, R.raw.perfect);
            sweet = MediaPlayer.create(context, R.raw.sweet);
            excellent = MediaPlayer.create(context, R.raw.excellent);
            goodthinking = MediaPlayer.create(context, R.raw.goodthinking);
            greatjob = MediaPlayer.create(context, R.raw.greatjob);
            notbad = MediaPlayer.create(context, R.raw.notbad);
            thatstheway = MediaPlayer.create(context, R.raw.thatstheway);
            youdidit = MediaPlayer.create(context, R.raw.youdidit);
            yes = MediaPlayer.create(context, R.raw.yes);
    
            switch (random.nextInt(11)) {
    
                case 0:
                    cool.start();
                    break;
                case 1:
                    good.start();
                    break;
                case 2:
                    perfect.start();
                    break;
                case 3:
                    sweet.start();
                    break;
                case 4:
                    excellent.start();
                    break;
                case 5:
                    goodthinking.start();
                    break;
                case 6:
                    greatjob.start();
                    break;
                case 7:
                    notbad.start();
                    break;
                case 8:
                    thatstheway.start();
                    break;
                case 9:
                    youdidit.start();
                    break;
                case 10:
                    yes.start();
                    break;
    
            }
        }
    }   
    

    Call methods of regular java file in activity like this.

    import android.app.Activity;
    import android.os.Bundle;
    public class testing002 extends Activity {
    private Sounds myotherclass;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.numeracy);
            new Sounds().Randomsoundforrightanswer(this);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two classes. I want to have a button on class 1
I have created two viewController classes such that one is superclass of another.i have
Say I have two classes created work and workItem. CWorker *work = new CWorker();
I have two classes with many-to-many relation so I created a join table in-between
I have two model classes, say parent and child. Parents are created first, and
I have created two WindowSurface (WPF), and I want to navigate betwen them. I've
I have created two DbContexts, one is for application configuration, the second is for
Lets say I have two different classes with a different number of arguments: class
I have created two classes as interface / implementation classes, and wish to pass
I have two classes like the following: class Super(object): def __init__(self, arg): self.arg =

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.