0

I want to show the initial Activity once for the first time app starts. I wrote such code in main Activity:

@Override
public void onResume() {
    super.onResume();
    SharedPreferences p = getPreferences(Context.MODE_PRIVATE);
    if (p.getBoolean(STATE_INIT, true)) {
        Intent intent = new Intent(this, GenderActivity.class);
        startActivityForResult(intent, REQUEST_1);
    }
}

Initial Activity appears and then app crashes. Could some comment what's the problem either suggest another way to show app initial activity?

Exception log:

07-19 01:54:45.997 3494-3494/ru.j_soft.contact E/AndroidRuntime: FATAL EXCEPTION: main
                                                                 Process: ru.j_soft.contact, PID: 3494
                                                                 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.RadioGroup.getCheckedRadioButtonId()' on a null object reference
                                                                     at ru.j_soft.contact.MainActivity.onSaveInstanceState(MainActivity.java:392)
                                                                     at android.app.Activity.performSaveInstanceState(Activity.java:1298)
                                                                     at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1289)
                                                                     at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4088)
                                                                     at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3490)
                                                                     at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3550)
                                                                     at android.app.ActivityThread.-wrap20(ActivityThread.java)
                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                     at android.os.Looper.loop(Looper.java:148)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-19 01:54:50.227 3494-3494/ru.j_soft.contact I/Process: Sending signal. PID: 3494 SIG: 9
Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154

0 Answers0