Android getlastknownlocation returns null

前端 未结 1 1054
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 16:27

I\'m calling getLastKnownLocation for the GPS provider and it\'s returning null. The docs say this might happen if the provider isn\'t enabled, but I know it is. Is it possi

相关标签:
1条回答
  • 2020-11-28 16:39

    Is it possible for the provider to return null if no last known location exists?

    Yes. In fact, much of the time, it will return null, because nothing is causing GPS to acquire fixes. GPS is usually powered down to save on battery life. See Obtaining User Location for the recipe for finding your location.

    I don't see where the docs say "may return null if no last known location exists"

    The documentation has its flaws.

    0 讨论(0)
提交回复
热议问题