Android: Starting an intent inside of onCreate is causing an infinite loop / crash
<p>I'm pretty new to Android/java, and have come up against my first head-scratcher.</p>

<p>I'm trying to conditionally change the starting view based on if a user is logged in (I've set is_logged_in already, here, to more simply illustrate the problem).</p>

<p>Many thanks.</p>

<pre><code>public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        boolean is_logged_in = false;

        if(is_logged_in) {
            setContentView(R.layout.activity_main);
        } else {
            menu_sign_up(); // How would I pass the View?
        }
    }

    // Doesn't work, at least when called inside of MainActivity's onCreate
    public void menu_sign_up(/* View view */) {
        Intent intent = new Intent(this, SignUp.class);
        startActivity(intent);
    }

    // Example of a working method, at least when called from android:onClick in XML
    public void menu_sign_in(View view) {
        Intent intent = new Intent(this, SignIn.class);
        startActivity(intent);
        overridePendingTransition(0,0);
    }
}

public class SignUp extends MainActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sign_up);
    }

    // ...
}
</code></pre>

<p><em><strong></em>**<em>*</em>**<em></strong> Truncated Stack Trace Below <strong></em>**<em>*</em>****</strong> (adb logcat *:W)</p>

<pre><code>W/ActivityManager(19583): Activity idle timeout for HistoryRecord{40953fd8 com.example.digitalkarmaeclipse/.SignUp}
W/ActivityManager(): Activity idle timeout for HistoryRecord{}
W/ActivityManager(21900): Launch timeout has expired, giving up wake lock!
W/ActivityManager(21900): Activity idle timeout for HistoryRecord{40a23580 com.example.digitalkarmaeclipse/.MainActivity}
W/ActivityManager(21900): Activity idle timeout for HistoryRecord{40a2c6f8 com.example.digitalkarmaeclipse/.SignUp}
W/ActivityManager(21900): Activity idle timeout for HistoryRecord{40a30100 com.example.digitalkarmaeclipse/.SignUp}
W/ActivityManager(21900): Activity idle timeout for HistoryRecord{40a338e8 com.example.digitalkarmaeclipse/.SignUp}
W/ActivityManager(21900): Activity idle timeout for HistoryRecord{40a376e0 com.example.digitalkarmaeclipse/.SignUp}
</code></pre>
