I'm really having problems resolving this.
The 'HandleNewTag' method is in the Droid MainActivity class. It's a non static but complains about the 'MainPage.HandleNFC' method it's calling, so I changed that to static and it didn't error.
The 'MainPage.HandleNFC' method also calls a method which was non static. I changed it to a static void to stop the error. Then inside that method, where it sets some properties of a XAML control, it complains that the control is not static which I am unable to change.
I've searched high and low on the internet to resolve this and although I can find similar errors, none of them refer to a non static control issue.
MainActivity.cs
public void HandleNewTag(object sender, NfcFormsTag e)
{
//MainPage mp = new MainPage();
byte[] bytes = e.Id;
Console.WriteLine(BitConverter.ToString(bytes));
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
Console.WriteLine(BitConverter.ToString(bytes));
// Call method to send byte stream across machine boundaries.
// Receive byte stream from beyond machine boundaries.
Console.WriteLine(BitConverter.ToString(bytes));
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
Console.WriteLine(BitConverter.ToString(bytes));
int result = BitConverter.ToInt32(bytes, 0);
MainPage.HandleNFC(result.ToString());
}
MainPage.xaml
public static void HandleNFC(string convertedtag)
{
addToReadout(convertedtag);
}
public static void addToReadout(string text)
{
Label label1 = new Label { Text = "Successfully clocked out @ " + text, TextColor = Color.Black };
StackLayout sl = new StackLayout();
readOut.Children.Add(label1);
readOut.BackgroundColor = Color.Black;
readOut.Children.Count();
}