Skip to content Skip to sidebar Skip to footer

StartActivity From String

I want to start Activity using Aktywnosc string from Kalkulator in Xamarin Android Visual Studio public class Kalkulator { public int Id { get; set; } public st

Solution 1:

Assuming this is the Activity that you are trying to start:

namespace SushiHangover
{
    [Activity(Name = "Resources.biblioteka.SomeActivity", Label = "SomeActivity")]
    public class SomeActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
        }
    }
}

Using the .Net Namespace/Class Name:

var intent = new Intent(this, Type.GetType("SushiHangover.SomeActivity"));
StartActivity(intent);

Using the Java Package/Class Name:

var intent = new Intent(this, Java.Lang.Class.ForName("Resources.biblioteka.SomeActivity"));
StartActivity(intent);

Post a Comment for "StartActivity From String"