I am developing an Android app and I am using a library I wrote. This library has a class that contains some static fields. One of them is a API key. This key is used by other classes in my library to make calls on a remote service.
I initialize the API key on my main Activity once when it is created and the savedInstanceState is null.
My problem lies in other activities as they sometimes use the correct API key when making calls with my library and sometimes they do not. It seems as if the API key has not been set.
In particular there is one activity that i call from my preferences activity that always fails as the API key is not set.
Are not static fields maintained across Activities as they are on normal Java applications? I thought that for a specific jvm instance, all static fields are retained. Is the Android platform using new jvm instances for new Activities?