Is MapsInitializer.initialize() thread-safe?

android, google-maps-android-api-2, multithreading

Solution

The best thing about `MapsInitializer` is that you can forget about it completly.

From the documentation you linked to:

If you are using MapFragment or MapView and have already obtained a (non-null) GoogleMap by calling getMap() on either of these classes, then it is not necessary to call this.

If you have problems obtaining non-null `GoogleMap` this is not to be resolved by `MapsInitializer`, but rather updating Google Play Services on the device.

Problem

I am using MapsInitializer.initialize(...) method to prepare Google Maps Android API v2 internals for my MapView. Currently it gets called during hosting Fragment's onCreateView() on an UI-thread, and this causes some noticable hickup before this fragment gets shown. Therefore I'm thinking about putting this call in some thread/AsyncTask to perform init in the background. Documentation doesn't mention if it is safe to do so, maybe fellow developers here know the answer? :)

Original source