DEV Community

John Melody Me
John Melody Me

Posted on

Answer: Start a new Activity from non Activity class

For Easy Usage you can a method for this particular method:

public class Something
{
   public static void navigate(Context context,  Class<?> nameOfClass)
    {
        Intent i = new Intent(context, nameOfClass);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
}

can be called in other class and method everytime by calling this:

Something.navigate(activityName.this, classYourWantTONavigateTo.class);

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started