I want to get an intent with an boolean from the second activity to my first activity. But now the application checks the intent and I get a null pointer exception directly, how can I skip the first check that happens and go to the second activity, and from there send it back to the first without getting the exception? I get the exception at :
Boolean backButton=fromStartActivity.getExtras().getBoolean("backPress");
Some of my Main Activity code:
  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /* Load the view and display it */
        setContentView(R.layout.activity_main);
        Firebase.setAndroidContext(this);
        Intent fromStartActivity = getIntent();
        Boolean backButton=fromStartActivity.getExtras().getBoolean("backPress");
        if(backButton){
            logout();
            Intent back = new Intent(Intent.ACTION_MAIN);
            back.addCategory(Intent.CATEGORY_HOME);
            back.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            //startActivity(back);
            finish();
            System.exit(0);
        }
The second activity:
 @Override
    public void onBackPressed(){
        super.onBackPressed();
        backButton=true;
        Intent fromBack = new Intent(StartActivity.this,MainActivity.class);
        fromBack.putExtra("backPress",backButton);
        startActivity(fromBack);
    }
 
     
     
     
    