Start an Activity from another Activity on Xamarin Android

Lacho picture Lacho · Oct 24, 2014 · Viewed 24.9k times · Source

I found this java code to create a generic method to start any activity from other activity.

public void gotoActivity(Class activityClassReference)
{
    Intent i = new Intent(this,activityClassReference);
    startActivity(i);
}

How can I convert that code to c# for xamarin-Android?

Thanks in advance.

Answer

Stam picture Stam · Oct 24, 2014

You can write:

public void GoToActivity(Type myActivity)
{
            StartActivity(myActivity);
}

and call it like:

 GoToActivity(typeof(ActivityType));

or just write:

StartActivity(typeof(ActivityType));