MapView
getMap()
метод может возвращать значение null. Я знаю, что это намеренное поведение Google.
Может ли кто-нибудь предоставить окончательное описание того, когда и при каких обстоятельствах метод getMap()
возвращает null?
Я знаю, что если Google Services недоступны на данном устройстве, getMap()
вернет значение null. Эта возможность относительно хорошо документирована. Меня больше интересует неопределенный другой случай, когда даже когда службы Google установлены на устройстве, getMap()
все равно может возвращать нуль.
Мое предположение до сих пор заключается в том, что есть некоторая инициализация базовой системы карт, в течение которой ваш код может выполняться и получать нулевую карту.
Правильно ли я в своем предположении?
Есть ли какое-либо конкретное место в жизненном цикле Activity или Fragment, где мы можем окончательно получить ненулевой GoogleMap
(если мы предполагаем, что установлен сервис Google Services IS)?
Моя цель в задании этого вопроса состоит в том, чтобы предотвратить литерию ошибок if(mapView.getMap() != null)
, замусоренных во всем моем коде. Кроме того, этот вопрос по-прежнему появляется на регулярной основе здесь, в StackOverflow, и я хотел бы узнать, можем ли мы понять правду о том, что именно происходит с MapView
и getMap()