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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:26:07+00:00 2026-05-23T01:26:07+00:00

EDIT: woah … somehow i replaced this question with another one i was asking,

  • 0

EDIT: woah … somehow i replaced this question with another one i was asking, glad there is this rollback feature

this specific question deals with the getter from my previous question

public class Impacts extends Activity implements View.OnClickListener
{
    boolean[] impactsb = new boolean[] {false, false, false, false, false, false, false, false}-
    public void onCreate (Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState)
...

    String getImpacts ()
    {
    String[] impactsn = new String[length];
    Resources myResources = this.getResources();
    impactsn = myResources.getStringArray(R.array.impacts);
    StringBuilder impactss = new StringBuilder();
    for (int i = 0; i < length; i ++)
        {
        if (impactsb[i])
            impactss.append(impactsn[i] + " | ");
        }
    if (String.valueOf(impactss) != "")
        impactss.insert(0, "Impacts: ");
    return String.valueOf(impactss);
    }

with these errors:

Impacts(ContextWrapper).getResources() line: 80
Impacts.getImpacts() line: 78

the final bracket of the below code:

@Override
public Resources getResources()
{
    return mBase.getResources();
}

and this line of code respectively:

impactsn = getResources().getStringArray(R.array.impacts);

here is my strings.xml (the relevent parts anyway)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="impacts">
        <item>GasOilChemical Pollutants</item>
        <item>Ghost Fishing</item>
        <item>Marsh Damage</item>
        <item>Navigational Hazard</item>
        <item>Shellfish Damage</item>
        <item>Waste Pollution</item>
        <item>Wildlife Entanglement</item>
        <item>Other</item>
    </string-array>
</resources>

i originally had the first item as:

<item>Gas/Oil/Chemical Pollutants</item>

but fixed that, hoping that would at least change the error if not fixing the problem. but nope, same error. any help would be vastly appreciated, im not terribly familiar with the use of array, especially getting resources for an array.

Logcat for exception:

06-05 23:02:30.792: ERROR/AndroidRuntime(3905): FATAL EXCEPTION: main
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): java.lang.NullPointerException
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): at com.citsci.mardeb.Impacts.getImpacts(Impacts.java:79)
  • 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-23T01:26:08+00:00Added an answer on May 23, 2026 at 1:26 am

    i know this is poor coding, apologies in advance. so to fix this problem, i moved

    String[] impactsn;
    impactsn = getResources().getStringArray(R.array.impacts);
    

    to my main activity and made it static. now i refer to it within my Impacts class as (MainActivity).impactsn[]

    i know this is not how you are supposed to share objects between classes, but it seems to be the easiest way so far. this is yet another reason why i am regretting my decision to make all of my tabs seperate activities. if you have any suggestions or advice on how to fix this code without using static references or on reasons why all of my tabs should be the same activities, please chime in.

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

Sidebar

Related Questions

EDIT: There's now a doc page on this so this question is irrelevant, also
EDIT: This post was originally specific to ASP.NET, but after thinking about it I'm
Edit: The below question was answered by this . I have a new updated
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT After staring at this for 2 days, I do see one issue. I
EDIT : I've gotten the famous question badge with this question, so I figured
EDIT: This question was exceptionally dumb and made me look like a script kiddie,
EDIT: looking for this: http://diminishing.org/extending-formtastic-with-a-sprinkle-of-jquery (If this works I'll answer my own question) I've
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot

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.