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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:44:59+00:00 2026-06-15T23:44:59+00:00

I’m trying to create a quiz game, but when I click on the response

  • 0

I’m trying to create a quiz game, but when I click on the response button, I get a NullPointerException.

It seems all variables are initialized, can anyone help me?

This is the class:

public class QActivity extends Activity {

    protected int qst = 0;
    protected int err = 0;
    protected String mode = "";
    protected Intent intent;
    protected ArrayList<Integer> tb;
    protected Integer x = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_q);
        Button r1 = (Button) findViewById(R.id.rep1);
        Button r2 = (Button) findViewById(R.id.rep2);
        Button r3 = (Button) findViewById(R.id.rep3);
        TextView txt = (TextView) findViewById(R.id.questiontxt);
        Question q = new Question();
        DatabaseHelper myDbHelper = new DatabaseHelper(this);

        tb = getIntent().getExtras().getIntegerArrayList("tb");

        mode = getIntent().getExtras().getString("Mode");
        qst = getIntent().getExtras().getInt("qst");
        err = getIntent().getExtras().getInt("err");

        if (mode.equals("25")) {
            x = 0;

            do {
                x = (int) (Math.random() * 57);

            } while (Verif(x, tb) == true);

            tb.add(x);
            qst += 1;

            try {
                q = myDbHelper.getQuestion(x);
            } catch (SQLException sqle) {
                throw sqle;
            }

            txt.setText(q.getQuestion());
            r1.setText(q.getAnswer1());
            r2.setText(q.getAnswer2());
            r3.setText(q.getAnswer3());

            TextView t1 = (TextView) findViewById(R.id.questid);
            TextView t3 = (TextView) findViewById(R.id.questnumber);

            intent = new Intent(this, QActivity.class);
            intent.putExtra("Mode", mode);
            intent.putExtra("qst", qst);
            intent.putExtra("err", err);
            intent.putExtra("tab", tb);
        }

        r1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(intent);
            }
        });

    }

    public boolean Verif(int n, ArrayList<Integer> tbl) {
        for (Integer s : tbl) {
            if (s == n)
                return true;
        }
        return false;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_q, menu);
        return true;
    }

}

And this is LogCat output:

12-12 00:27:47.233: W/dalvikvm(7142): threadid=1: thread exiting with uncaught exception (group=0x40c471f8)
12-12 00:27:47.233: E/AndroidRuntime(7142): FATAL EXCEPTION: main
12-12 00:27:47.233: E/AndroidRuntime(7142): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dreamappz.alamalmaarefa/com.dreamappz.alamalmaarefa.QActivity}: java.lang.NullPointerException
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.os.Looper.loop(Looper.java:137)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.ActivityThread.main(ActivityThread.java:4511)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at java.lang.reflect.Method.invokeNative(Native Method)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at java.lang.reflect.Method.invoke(Method.java:511)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at dalvik.system.NativeStart.main(Native Method)
12-12 00:27:47.233: E/AndroidRuntime(7142): Caused by: java.lang.NullPointerException
12-12 00:27:47.233: E/AndroidRuntime(7142):     at com.dreamappz.alamalmaarefa.QActivity.Verif(QActivity.java:87)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at com.dreamappz.alamalmaarefa.QActivity.onCreate(QActivity.java:47)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.Activity.performCreate(Activity.java:4470)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
12-12 00:27:47.233: E/AndroidRuntime(7142):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
12-12 00:27:47.233: E/AndroidRuntime(7142):     ... 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-15T23:44:59+00:00Added an answer on June 15, 2026 at 11:44 pm

    You should change this line:

    intent.putExtra("tab", tb);
    

    to this:

    intent.putExtra("tb", tb);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

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.