Search code examples
javaandroidandroid-activity

How do you start a new window activity in Android Studio?


I tried several things, such as:

Intent i = new Intent(this, myActivity.class);
startActivity(i)

Where it tells me it cannot resolve symbol 'myActivity'

I tried Context.startActivity and extended the class by Context, at that point it just wants me to implement every single method of Context into my class.

How can I just simply make a new activity visible to the user after an if condition runs into true?


Solution

  • Intent i = new Intent(CurrentActivity.this, myActivity.class);
    startActivity(i)
    

    Here myActivity is the name of your second activity (Which you want to open from this intent).

    CurrentActivity is the name of your current activity