I am trying to send the text data entered in popquizisabout class to the popquiz class and set it in text view but my app crashes when i do so
this is the popquizisabout class
public class PopQuizIsAbout extends Activity implements OnClickListener {
EditText person;
Button start, startforresult;
TextView result;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.popquizisabout);
initialize();
start.setOnClickListener(this);
startforresult.setOnClickListener(this);
}
private void initialize() {
// TODO Auto-generated method stub
person = (EditText) findViewById(R.id.Etperson);
start = (Button) findViewById(R.id.Bsa);
startforresult = (Button) findViewById(R.id.Bsar);
result = (TextView) findViewById(R.id.Tvresult);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.Bsa:
String bread = person.getText().toString();
Bundle basket = new Bundle();
basket.putString("keyid", bread);
Intent a = new Intent(PopQuizIsAbout.this,PopQuiz.class);
a.putExtras(basket);
startActivity(a);
break;
case R.id.Bsar:
break;
}
}
}
this is the popquiz class
public class PopQuiz extends Activity implements OnClickListener,
OnCheckedChangeListener {
TextView name, thought;
Button returndata;
RadioGroup selectionlist;
String gotBread;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.popquiz);
initialize();
returndata.setOnClickListener(this);
selectionlist.setOnCheckedChangeListener(this);
Bundle gotbasket = getIntent().getExtras();
gotBread = gotbasket.getString("keyid");
name.setText(gotBread);
}
private void initialize() {
// TODO Auto-generated method stub
name = (TextView) findViewById(R.id.Tvname);
thought = (TextView) findViewById(R.id.Tvthought);
returndata = (Button) findViewById(R.id.Breturn);
selectionlist = (RadioGroup) findViewById(R.id.rganswers);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
@Override
public void onCheckedChanged(RadioGroup group, int id) {
// TODO Auto-generated method stub
switch (id) {
case R.id.rblazy:
break;
case R.id.rbdream:
break;
case R.id.rbboth:
break;
}
}
}
logcat
08-17 23:47:26.512: E/MediaPlayer(19172): Should have subtitle controller already set
08-17 23:47:26.543: I/Adreno-EGL(19172): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1__release_AU ()
08-17 23:47:26.543: I/Adreno-EGL(19172): OpenGL ES Shader Compiler Version: E031.24.00.08
08-17 23:47:26.543: I/Adreno-EGL(19172): Build Date: 03/07/14 Fri
08-17 23:47:26.543: I/Adreno-EGL(19172): Local Branch:
08-17 23:47:26.543: I/Adreno-EGL(19172): Remote Branch: quic/LNX.LA.3.5.1_RB1.1
08-17 23:47:26.543: I/Adreno-EGL(19172): Local Patches: NONE
08-17 23:47:26.543: I/Adreno-EGL(19172): Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018 + f2fd134 + NOTHING
08-17 23:47:26.577: D/OpenGLRenderer(19172): Enabling debug mode 0
08-17 23:47:29.363: E/MediaPlayer(19172): Should have subtitle controller already set
08-17 23:49:36.107: D/AndroidRuntime(19172): Shutting down VM
08-17 23:49:36.107: W/dalvikvm(19172): threadid=1: thread exiting with uncaught exception (group=0x41662d40)
08-17 23:49:36.117: E/AndroidRuntime(19172): FATAL EXCEPTION: main
08-17 23:49:36.117: E/AndroidRuntime(19172): Process: com.sagarapp, PID: 19172
08-17 23:49:36.117: E/AndroidRuntime(19172): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sagarapp/com.sagarapp.PopQuiz}: java.lang.NullPointerException
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.ActivityThread.access$800(ActivityThread.java:139)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.os.Handler.dispatchMessage(Handler.java:102)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.os.Looper.loop(Looper.java:136)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.ActivityThread.main(ActivityThread.java:5086)
08-17 23:49:36.117: E/AndroidRuntime(19172): at java.lang.reflect.Method.invokeNative(Native Method)
08-17 23:49:36.117: E/AndroidRuntime(19172): at java.lang.reflect.Method.invoke(Method.java:515)
08-17 23:49:36.117: E/AndroidRuntime(19172): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-17 23:49:36.117: E/AndroidRuntime(19172): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-17 23:49:36.117: E/AndroidRuntime(19172): at dalvik.system.NativeStart.main(Native Method)
08-17 23:49:36.117: E/AndroidRuntime(19172): Caused by: java.lang.NullPointerException
08-17 23:49:36.117: E/AndroidRuntime(19172): at com.sagarapp.PopQuiz.onCreate(PopQuiz.java:30)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.Activity.performCreate(Activity.java:5248)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
08-17 23:49:36.117: E/AndroidRuntime(19172): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
08-17 23:49:36.117: E/AndroidRuntime(19172): ... 11 more
08-17 23:49:37.344: I/Process(19172): Sending signal. PID: 19172 SIG: 9
08-17 23:49:37.591: I/Adreno-EGL(19849): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1__release_AU ()
08-17 23:49:37.591: I/Adreno-EGL(19849): OpenGL ES Shader Compiler Version: E031.24.00.08
08-17 23:49:37.591: I/Adreno-EGL(19849): Build Date: 03/07/14 Fri
08-17 23:49:37.591: I/Adreno-EGL(19849): Local Branch:
08-17 23:49:37.591: I/Adreno-EGL(19849): Remote Branch: quic/LNX.LA.3.5.1_RB1.1
08-17 23:49:37.591: I/Adreno-EGL(19849): Local Patches: NONE
08-17 23:49:37.591: I/Adreno-EGL(19849): Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018 + f2fd134 + NOTHING
08-17 23:49:37.625: D/OpenGLRenderer(19849): Enabling debug mode 0
popquiz xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/status"
android:layout_gravity="center"/>
<RadioGroup
android:id="@+id/rganswers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<RadioButton
android:id="@+id/rblazy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lazy" />
<RadioButton
android:id="@+id/rbdream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dream" />
<RadioButton
android:id="@+id/rbboth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/both" />
</RadioGroup>
<TextView
android:id="@+id/Tvthought"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/status"
android:layout_gravity="center"/>
<Button
android:id="@+id/Breturn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="return"
android:layout_gravity="center"/>
</LinearLayout>
popquizisabout xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:id="@+id/Etperson"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text"
>
<requestFocus />
</EditText>
<Button
android:id="@+id/Bsa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/start"
android:layout_below="@+id/Etperson"
android:layout_alignParentRight="true"
/>
<Button
android:id="@+id/Bsar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/startresult"
android:layout_toLeftOf="@+id/Bsa"
android:layout_alignTop="@+id/Bsa"
android:textSize="15sp"
/>
<TextView
android:id="@+id/Tvresult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/status"
android:layout_below="@+id/Bsar"
android:layout_centerInParent="true"
/>
</RelativeLayout >