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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:03:57+00:00 2026-06-10T04:03:57+00:00

I’m trying to start an Activity, which includes Bundles. I’m trying to set this

  • 0

I’m trying to start an Activity, which includes Bundles. I’m trying to set this bundles to be null for now since nothing has yet been passed on to this activity.

public class DailyActivities  extends Activity implements OnClickListener{
     TextView scoreA
    int gotA;
    int counter_score;

@Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
          counter_score=0;
          int questions_1 = 26;

        initialize();

          ///////PSEUDO CODE...this is where Im trying to say, if no bundled is passed,
          ////////then setText for scoreA to the int counter score, 
           ////////so that the activity doesn't crash due to null pointer exception////
        Bundle gotA = getIntent().getExtras();
        if(gotA == null){ 
        scoreA.setText(counter_score);
          }else if (gotA != null){
        gotLetterA = gotA.getInt("key");
         counter_score = gotLetterA;
         int percentage = (int)( gotLetterA * 100.0 / questions_1 + 0.5);
         scoreA.setText(percentage);

   }   
}

Currently activity crashes with the a android.resources not found error

edit- added error log

08-24 10:39:33.180: E/AndroidRuntime(21177): FATAL EXCEPTION: main
08-24 10:39:33.180: E/AndroidRuntime(21177): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.app/com.test.app.DailyActivities}: android.content.res.Resources$NotFoundException: String resource ID #0x0
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.os.Looper.loop(Looper.java:137)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-24 10:39:33.180: E/AndroidRuntime(21177): at java.lang.reflect.Method.invokeNative(Native Method)
08-24 10:39:33.180: E/AndroidRuntime(21177): at java.lang.reflect.Method.invoke(Method.java:511)
08-24 10:39:33.180: E/AndroidRuntime(21177): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-24 10:39:33.180: E/AndroidRuntime(21177): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-24 10:39:33.180: E/AndroidRuntime(21177): at dalvik.system.NativeStart.main(Native Method)
08-24 10:39:33.180: E/AndroidRuntime(21177): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.content.res.Resources.getText(Resources.java:229)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.widget.TextView.setText(TextView.java:3620)
08-24 10:39:33.180: E/AndroidRuntime(21177): at com.MovilTeacher_titan.app.DailyActivities.onCreate(DailyActivities.java:164)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.Activity.performCreate(Activity.java:5008)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-24 10:39:33.180: E/AndroidRuntime(21177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)

Soooooo here is the solution, I was being dense lol

Bundle gotA = getIntent().getExtras();{ 
if(gotA == null){ scoreA.setText("0%"); 
}else { 
myPkg = gotA.getInt("key"); 
counter_score = myPkg; 
int percentage = (int)( myPkg * 100.0 / questions_1 + 0.5);

scoreA.setText(""+percentage); 
} 
}
  • 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-10T04:03:59+00:00Added an answer on June 10, 2026 at 4:03 am

    percentage is an int. Your call to setText(percentage) is expecting a resource ID, not a percentage value.

    Try this: setText(“”+percentage).

    This will convert percentage to a string and pass that to setText() instead.

    p.s. WOUNDEDSteveJones is right too, you need a call to findViewById(), but I’m guessing you have that somewhere or this app would have crashed in a different way.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm trying to select an H1 element which is the second-child in its group
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.