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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:16:25+00:00 2026-05-24T18:16:25+00:00

I am working off another example (found here Loading MP3s into the Sound Pool

  • 0

I am working off another example (found here Loading MP3s into the Sound Pool in Android). but for some reason I am ending up with two onCreate() methods and if I delete one I am getting errors.

I am trying to load the MP3s into the Soundpool once and then call them in other activities.

My code:

class MyApp extends Application {
    private static MyApp singleton;

    private static SoundPool mSoundPool;

    public onCreate() { // ##### Deleting this gives me errors ###, not deleting it gives me 1 error.
         super.onCreate();
         singleton = this;
         mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);// Just an example
    }

    public static MyApp getInstance() {
         return singleton;
    }

    public SoundPool getSoundPool() {
         return mSoundPool;
    }
}


public class TestAndroidGlobalsActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
  • 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-24T18:16:26+00:00Added an answer on May 24, 2026 at 6:16 pm

    Your code only has one onCreate method per class. They serve different purposes and are called when each of those classes is created by the OS.

    Your MyApp.onCreate is called when the application is created and sets up application-wide state inside your MyApp class.

    Your TestAndroidGlobalsActivity.onCreate is called when the Activity is created and sets the state for that specific activity an initializes its UI.

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

Sidebar

Related Questions

I'm going off this great example I found, it works, but when I have
First off, I'm working on an app that's written such that some of your
I've been working on and off with a team that's developing an iPhone app.
First off I should say that I don't have any experience in working with
I'm working with large numbers that I can't have rounded off. Using Lua's standard
First off, let me start by saying that I am totally new to working
I'm working on an app that grabs and installs a bunch of updates off
My wording might be a bit off, but I wonder if there's an open-source
Thanks to Code Poet, I am now working off of this code to parse
I am working on implementing a function that would execute another function a few

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.