Reputation: 505
I am using Xamarin I am wanting to start a new activity that is called AutoLinkActivity.
Here is my code:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Text.Util;
namespace TestTextViewAutoLink
{
[Activity (Label = "TestTextViewAutoLink", MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
Intent intent= new Intent(this.ApplicationContext, AutoLinkActivity);
intent.SetFlags(ActivityFlags.NewTask);
StartActivity(intent);
}
}
}
The build error that I am getting is:
'TestTextViewAutoLink.AutoLinkActivity' is a 'type' but is used like a 'variable'
May I please have some help to get this working?
Thanks in advance
Upvotes: 2
Views: 8310
Reputation: 152
You have to use:
typeof(NameofyourActivity)
Try this if you don't want use intent and start it directly:
protected override void OnCreate (Bundle bundle)
{
StartActivity(typeof(AutoLinkActivity));
}
Upvotes: 0
Reputation: 20764
Use this:
Intent intent= new Intent(this.ApplicationContext, typeof(AutoLinkActivity));
the second parameter has to be the type of the activity class, not the class itself.
Upvotes: 5