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

  • Home
  • SEARCH
  • 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 8870277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:41:02+00:00 2026-06-14T17:41:02+00:00

I know the general matter has been discussed in this stackoverflow topic already (constructors

  • 0

I know the general matter has been discussed in this stackoverflow topic already (constructors never return null), but considering its significance in this concrete matter, I would like to know if the official Android documentation of the SoundPool constructor is wrong then:

Constructor. Returns
a SoundPool object, or null if creation failed

I’m asking this because we’re talking about no less than the official documentation of Android that has been up for years (in case of SoundPool).

Checking the Android source code, the SoundPool throws a RuntimeException in case of an error in constructor. (The pre-2.3 Android did not even throw an exception.) Perhaps the documentation tries to express that if the exception is caught, then the variable where I intended to store the object reference remains null? In this case, the doc is still very poorly worded. Am I missing something?

EDIT: considering this might not be a very content-rich question (even though it may be useful — see my comments), a simple Yes or No would be sufficient, and then the thread can get closed. I want to make sure I haven’t overlooked anything.

  • 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-14T17:41:03+00:00Added an answer on June 14, 2026 at 5:41 pm
    1. Constructors cannot return null. They can throw exceptions, but they cannot return anything but the object which they create if successful.
    2. As you have found, SoundPool may throw an exception in it’s constructor. You can ignore it. They specifically chose to throw a RuntimeException (on 2.3+) as opposed to a checked exception which indicates the API designers consider this a good enough reason to crash an app and that does not need to be routinely handled.
    3. If you really must handle the exception then I would simply notify the user and quit immediately.

    So no, it can’t return null. But if you handle the exception then yes, your reference to the object will be null because the constructor did not complete.

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

Sidebar

Related Questions

I know that this topic has been beaten to death, but it seems that
I know this SO question, but it deals with the subject in more general
I know that this question is general, but I couldn't find a tutorial or
i just want to know a general information about this particular information. Any good
I know it is a general question but I need your recommodations about a
I know, the general answer will be yes, but here is my situation. I
People often say I should reuse short-living objects in general, but I don't know
So, maybe this is a bad design; I don't know. But say I have
I know in general it is a good practice to move as much processing
I know the general difference between value type and reference type, and I also

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.