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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:31:04+00:00 2026-06-13T01:31:04+00:00

This activity is supposed to call another activity, but instead it force closes the

  • 0

This activity is supposed to call another activity, but instead it force closes the application.

package com.example.helloworld;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Data extends Activity implements OnClickListener {

    Button start, startFor;
    EditText sendET;
    TextView gotAnswer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.get);
        initialize();
    }

    private void initialize() {
        // TODO Auto-generated method stub
        start = (Button) findViewById(R.id.bSA);
        startFor = (Button) findViewById(R.id.bSAFR);
        sendET = (EditText) findViewById(R.id.etSend);
        gotAnswer = (TextView) findViewById(R.id.tvGot);
        start.setOnClickListener(this);
        startFor.setOnClickListener(this);
    }

    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.bSA:
            String bread = sendET.getText().toString();
            Bundle basket = new Bundle();
            basket.putString("key", bread);

            Intent a = new Intent(Data.this, OpenedClass.class);
            a.putExtras(basket); 
            startActivity(a);
            break;

        case R.id.bSAFR:
            Intent i = new Intent(Data.this, OpenedClass.class);
            startActivityForResult(i,0);
            break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
    }

}

This is the other Activity that is to be called:

package com.example.helloworld;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class OpenedClass extends Activity implements OnClickListener,
        OnCheckedChangeListener {

    TextView question, test;
    Button returnData;
    RadioGroup selectionList;
    String gotBread, setData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.send);
        initialize();
        Bundle gotBasket = getIntent().getExtras();
        gotBread = gotBasket.getString("key");
        question.setText(gotBread);

    }

    private void initialize() {
        // TODO Auto-generated method stub
        question = (TextView) findViewById(R.id.tvQuestions);
        test = (TextView) findViewById(R.id.tvText);
        returnData = (Button) findViewById(R.id.bResults);
        selectionList = (RadioGroup) findViewById(R.id.rgAnswers);
        returnData.setOnClickListener(this);
        selectionList.setOnCheckedChangeListener(this);


    }

    public void onClick(View v) {
        // TODO Auto-generated method stub

    }

    public void onCheckedChanged(RadioGroup arg0, int arg1) {
        // TODO Auto-generated method stub
        switch (arg1) {
        case R.id.rChoice1:
            setData="ABC";
            break;
        case R.id.rChoice2:
            setData="MNO";
            break;
        case R.id.rChoice3:
            setData="XYZ";
            break;
        }
        test.setText(setData);
    }

}

This is my AndroidMaifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloworld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
    <uses-permission android:name="android.permission.SET_WALLPAPER"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Splash"
            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=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>

            </intent-filter>
        </activity>
        <activity
            android:name=".Menu"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="com.example.helloworld.MENU" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".TextPlay" android:label="@string/title_activity_main" >
        </activity>
         <activity
            android:name=".Email" android:label="@string/title_activity_main" >
        </activity>
        <activity
            android:name=".Camera" android:label="@string/title_activity_main" android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name=".Data" android:label="@string/title_activity_main" >
        </activity>
        <activity
            android:name=".OpenedClass" android:label="@string/title_activity_main" >
        </activity>
    </application>

</manifest>

Finally the LogCat logs:

10-17 10:36:56.423: D/AndroidRuntime(272): Shutting down VM
10-17 10:36:56.423: W/dalvikvm(272): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-17 10:36:56.453: E/AndroidRuntime(272): FATAL EXCEPTION: main
10-17 10:36:56.453: E/AndroidRuntime(272): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.OpenedClass}: java.lang.NullPointerException
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.os.Looper.loop(Looper.java:123)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.ActivityThread.main(ActivityThread.java:4627)
10-17 10:36:56.453: E/AndroidRuntime(272):  at java.lang.reflect.Method.invokeNative(Native Method)
10-17 10:36:56.453: E/AndroidRuntime(272):  at java.lang.reflect.Method.invoke(Method.java:521)
10-17 10:36:56.453: E/AndroidRuntime(272):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-17 10:36:56.453: E/AndroidRuntime(272):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-17 10:36:56.453: E/AndroidRuntime(272):  at dalvik.system.NativeStart.main(Native Method)
10-17 10:36:56.453: E/AndroidRuntime(272): Caused by: java.lang.NullPointerException
10-17 10:36:56.453: E/AndroidRuntime(272):  at com.example.helloworld.OpenedClass.initialize(OpenedClass.java:38)
10-17 10:36:56.453: E/AndroidRuntime(272):  at com.example.helloworld.OpenedClass.onCreate(OpenedClass.java:25)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-17 10:36:56.453: E/AndroidRuntime(272):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-17 10:36:56.453: E/AndroidRuntime(272):  ... 11 more
10-17 10:36:59.083: I/Process(272): Sending signal. PID: 272 SIG: 9

The problem is that the application compiles without errors but crashes when I try to invoke the activity. I’m not sure where the problem is. Is it the manifest?

  • 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-13T01:31:05+00:00Added an answer on June 13, 2026 at 1:31 am

    If I counted lines correctly (to line 38 of OpenedClass.java) the NPE is being generated at this line:

    returnData.setOnClickListener(this);
    

    inside OpenedClass.initialize(). The variable returnData is being initialize a couple of lines above by:

    returnData = (Button) findViewById(R.id.bResults);
    

    The problem is most likely that your layout (send.xml) does not have a bResults view so returnData is being assigned null.

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

Sidebar

Related Questions

RoomInfoActivity.java: http://pastebin.com/L9fFsFeH (note: this is the 3rd activity launched by the same application, not
I have a class that is supposed to call another activity depending on which
I have one SubjectTabActivity and i need to show listview on this activity. But
Hi i'm facing this problem. I have an application with 2 activities: -Activity A
I read some similar questions (for example at this link ), but the problem
This activity is used for login. It post the username and password to a
So i have this activity : public class settings_dock extends Activity { AlertDialog alert;
I have an activity that starts after a certain time. Once this activity starts,
I have this structure: Activity A has a ViewPager. The pages of a ViewPager
I'm binding to Service by this way: Activity class: ListenLocationService mService; @Override public void

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.