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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:25:21+00:00 2026-06-15T12:25:21+00:00

All of the commented out code in Results.java is all of the things I

  • 0

All of the commented out code in Results.java is all of the things I have tried with no success. I am having trouble passing an integer through to another activity by intents.

The below method is in my QuestionView.java class.

public void endQuiz() {
    Intent intent = new Intent(QuestionView.this, Results.class);
    intent.putExtra("correctAnswers", correctAnswers);
    intent.putExtra("wrongAnswers", wrongAnswers);
    startActivity(intent);
}

Results.java

public class Results extends Activity {

    QuestionView qv = new QuestionView();
    ArrayList<Question> queryList = qv.getQueries();

//  int cAswers = this.getIntent().getExtras("correctAnswers");
    int cAnswers = getIntent().getIntExtra("correctAnswers", -1);
    int wAnswers = getIntent().getIntExtra("wrongAnswers", -1);

/*  Bundle b = this.getIntent().getExtras();
    int cAnswers = b.getInt("correctAnswers");
    int wAnswers = b.getInt("wrongAnswers");*/

//  int cAnswer = getIntent().getIntExtra("correctAnswer");


//  if(getIntent().getIntExtra("correctAnswers") != null) {
//      int cAnswers = b.getInt("correctAnswers");
//  }

//  ArrayList<Question> questions = extras.getSparseParcelableArray("queries");

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.resultsmain);



/*      Bundle extras = getIntent().getExtras();
        int cAnswers = extras.getInt("correctAnswers");
        int wAnswers = extras.getInt("wrongAnswers");*/


        Button homeBtn = (Button)findViewById(R.id.homeBtn);
        Button highscoresBtn = (Button)findViewById(R.id.highscoresBtn);

        homeBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                Intent intent1 = new Intent(Results.this, MainMenu.class);
                startActivity(intent1);
            }
        });

        highscoresBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                Intent intent2 = new Intent(Results.this, Highscores.class);
                startActivity(intent2);
            }
        });

        showResults();
    }

    public void showResults() {

        ArrayList<TextView> tList = new ArrayList<TextView>(10);

        TextView header = (TextView)findViewById(R.id.header);
        TextView q1 = (TextView)findViewById(R.id.q1);
        TextView q2 = (TextView)findViewById(R.id.q2);
        TextView q3 = (TextView)findViewById(R.id.q3);
        TextView q4 = (TextView)findViewById(R.id.q4);
        TextView q5 = (TextView)findViewById(R.id.q5);
        TextView q6 = (TextView)findViewById(R.id.q6);
        TextView q7 = (TextView)findViewById(R.id.q7);
        TextView q8 = (TextView)findViewById(R.id.q8);
        TextView q9 = (TextView)findViewById(R.id.q9);
        TextView q10 = (TextView)findViewById(R.id.q10);

        tList.add(q1);
        tList.add(q2);
        tList.add(q3);
        tList.add(q4);
        tList.add(q5);
        tList.add(q6);
        tList.add(q7);
        tList.add(q8);
        tList.add(q9);
        tList.add(q10);

        tList.get(0).setText(queryList.get(0).getQuery());

        if(queryList.get(0).getCorrectness() == true) {
            tList.get(1).setText("Changed to true");
        } else {
            tList.get(1).setText("DID NOT Change to true");
        }

        tList.get(2).setText(Integer.toString(cAnswers));
        tList.get(3).setText(Integer.toString(wAnswers));

/*      for(int i = 0; i < 10; i++) {
            tList.get(i).setText(queryList.get(i).getQuery());
            if(queryList.get(i).getCorrectness() == true) {
                tList.get(i).setTextColor(Color.GREEN);
            } else {
                tList.get(i).setTextColor(Color.RED);
            }
        }*/
    }
}

LogCat

12-04 11:52:33.342: E/AndroidRuntime(1128): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.test/com.example.test.Results}: java.lang.NullPointerException
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.os.Looper.loop(Looper.java:137)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.ActivityThread.main(ActivityThread.java:4745)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at java.lang.reflect.Method.invokeNative(Native Method)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at java.lang.reflect.Method.invoke(Method.java:511)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at dalvik.system.NativeStart.main(Native Method)
12-04 11:52:33.342: E/AndroidRuntime(1128): Caused by: java.lang.NullPointerException
12-04 11:52:33.342: E/AndroidRuntime(1128):     at com.example.test.Results.<init>(Results.java:21)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at java.lang.Class.newInstanceImpl(Native Method)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at java.lang.Class.newInstance(Class.java:1319)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
12-04 11:52:33.342: E/AndroidRuntime(1128):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
12-04 11:52:33.342: E/AndroidRuntime(1128):     ... 11 more
  • 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-15T12:25:23+00:00Added an answer on June 15, 2026 at 12:25 pm

    you are trying to get intent from QuestionView before onCreate method of Results.place your code for receiving in result in onCreate Change your Result Activity as:

    public class Results extends Activity {
        int cAnswers=0;
        int wAnswers=0;
        QuestionView qv = new QuestionView();
        ArrayList<Question> queryList = qv.getQueries();
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.resultsmain);
            cAnswers = getIntent().getIntExtra("correctAnswers", -1);
             wAnswers = getIntent().getIntExtra("wrongAnswers", -1);
           //your code here...
    

    NOTE : i already told you don’t Create an instance of Activity for accessing methods or fields from it. use Intent or Application class for Sharing data between Application Components like Activities

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

Sidebar

Related Questions

The code below prints out all comments for a given submissionid in chronological order.
I have this code to load a config file and read all the values
For example, in this piece of code, if line [a] is commented out, the
I have looked all over for pthread_join examples, I am having troubles debugging this
I've prepared this bit of code, and as you can see I've commented out
Ok, so I'm having a problem trying figure out the problem in my code.
This code works fine when the cur.execute() and db.commit() lines are commented out; i.e.
Here is the piece of code I am having trouble with as far as
Is there a plugin or tool in IntelliJ that will strip all comments out
In Visual Studio 2008, using Regex, how do I comment out all lines containing

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.