So I have a Custom object called connector which contains a threaded socket for communicating with an Arduino without locking the UI. But I want to access this socket from multiple screens/activities.
I tried using a static class to contain the object like in this answer:
Transfer Socket from one Activity to another
But I keep getting a "name does not exist in current context" error when trying to acces it from antoher activity.
here is the code for my storage class:
public class ConnectorManager
{
private static Connector connectorObject;
public static Connector GetConnector()
{
return connectorObject;
}
public static void SetConnector(Connector connector)
{
connectorObject = connector;
}
}
edit1: this is how im trying to use the class:
ConnectorManager.SetConnector(connector);
Connector connector = ConnectorManager.GetConnector();
edit2:
after deleting the code file and creating a new one the problem magically fixed itself