Hi,
I've been downloading offline map areas using a credential as seen below:

Whenever I set ArcGISRuntimeEnvironment.setApiKey("apiKey"), the preplannedMapAreas comes out as empty, but when I have not set the apiKey in the runtime environment, it returns the list. Same thing happens if I have not set the credential above and set the apiKey.
I would like to know if there is a way to set the apiKey locally in a function, instead of globally, so that I can still load the arcgis map with the apiKey, without making it so I cannot download the preplanned map area.
Alternatively, is there a way of loading an arcgis map without the api key, but using the credentials instead?
Thanks for reading!