This might be a silly question, but I don't get why a Service cannot access an Activity when it is instantiated/running. I have a static attribute (actually a HashMap) in my Activity, so I needed to access its content and copy to my Service (then be independent to run on the background). Whenever I try to access a class from my Service I get a NullPointer.
My code is basically this. Within the Activity:
// check if its static attribute is empty
startService(new Intent(MyService.class.getName()));
Within MyService (which extends Service):
serviceList = MainActivity.list; // Here I suppose I should clone my list
I just didn't want to maybe send it through Parcel or Serialization, because I have custom objects in this HashMap.
Any solutions/explanation?