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

The Archive Base Latest Questions

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

I am working on a project for my android class. I have three options

  • 0

I am working on a project for my android class. I have three options listed on my MainActivity, and when one is selected, the user goes to one of three activities: a) an activity to enter new student info, b) an activity which views all students on record, or c) an activity which allows tracking of a target students’ behaviour.
When I select the radio button for entering student info and click the ‘select’ button, all goes as it should, i.e. you are sent to the proper activity. However, when either of the other two options are selected, I get a null pointer exception. I have all three activities declared in my manifest.

Here is my class code:

    public void onButtonClicked (View v){
    RadioButton rdTrackBehaviour = (RadioButton)findViewById(R.id.radioOption2);
    RadioButton rdEnterStudent = (RadioButton)findViewById(R.id.radioOption1);
    RadioButton rdCurrentStudents = (RadioButton)findViewById(R.id.radioOption3);

            if(rdEnterStudent.isChecked()){
                Intent enterIntent = new Intent(MainActivity.this, EnterStudentActivity.class);
                startActivity(enterIntent);
            }
            if(rdTrackBehaviour.isChecked()){
                Intent onTaskIntent = new Intent(MainActivity.this, ActivityOnTaskBehaviour.class);
                MainActivity.this.startActivity(onTaskIntent);
            }
            else{
                if(rdCurrentStudents.isChecked()){
                    Intent currentStudentIntent = new Intent(MainActivity.this, StudentList.class);
                    startActivity(currentStudtenIntent);
                }
            }
}

And a snippet from my manifest:

    <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".EnterStudentActivity"
        android:label="@string/title_activity_enter_student" >
    </activity>
    <activity
        android:name=".ActivityOnTaskBehaviour"
        android:label="@string/title_activity_activity_on_task_behaviour" >
    </activity>
    <activity
        android:name=".StudentList"
        android:label="@string/title_activity_student_list" >
    </activity>
    <activity
        android:name=".Results"
        android:label="@string/title_activity_results" >
    </activity>
</application>

And my stackTrace:

11-25 19:47:39.735: E/AndroidRuntime(332): FATAL EXCEPTION: main
11-25 19:47:39.735: E/AndroidRuntime(332): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.behaviourtracker/com.example.behaviourtracker.ActivityOnTaskBehaviour}: java.lang.NullPointerException
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.os.Looper.loop(Looper.java:123)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.ActivityThread.main(ActivityThread.java:3683)
11-25 19:47:39.735: E/AndroidRuntime(332):  at java.lang.reflect.Method.invokeNative(Native Method)
11-25 19:47:39.735: E/AndroidRuntime(332):  at java.lang.reflect.Method.invoke(Method.java:507)
11-25 19:47:39.735: E/AndroidRuntime(332):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-25 19:47:39.735: E/AndroidRuntime(332):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-25 19:47:39.735: E/AndroidRuntime(332):  at dalvik.system.NativeStart.main(Native Method)
11-25 19:47:39.735: E/AndroidRuntime(332): Caused by: java.lang.NullPointerException
11-25 19:47:39.735: E/AndroidRuntime(332):  at com.example.behaviourtracker.ActivityOnTaskBehaviour.onCreate(ActivityOnTaskBehaviour.java:19)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-25 19:47:39.735: E/AndroidRuntime(332):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-25 19:47:39.735: E/AndroidRuntime(332):  ... 11 more

I’m a total rookie, and completely stumped. Have been looking around for an hour or two on the googles, and everyone seems to keep saying that it has to do with the activity not being registered in the manifest. Have I done that incorrectly, or is there another problem?
Also, I threw a try catch block around

            if(rdTrackBehaviour.isChecked()){
                Intent onTaskIntent = new Intent(MainActivity.this, ActivityOnTaskBehaviour.class);
                MainActivity.this.startActivity(onTaskIntent);
            }

With a log.d, but there was nothing in logcat….

  • 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-14T20:40:42+00:00Added an answer on June 14, 2026 at 8:40 pm

    Check line 19 of ActivityOnTaskBehaviour.java. You’re most likely trying to call an instance method on a null object on that line.

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

Sidebar

Related Questions

I'm having an Android GPS project for my CS class. Right now I'm working
I am currently working on android project where I want to have a text
While working on an AppEngine connected Android project, I occasionally have problems with RequestFactory
I'm working on a project in Android and I have a problem. I have
I am currently working on an android project. I am trying to have an
In my Android project I have 3 classes: 1st a List class contains a
I have dug out an old android project that I was working on a
I'm working on an Android project, and i have a lot of drawables. These
In an Android project I am working on I have a ListActivity that is
i am working on my first project with android and java and have very

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.