Replace default GPS signal provider on Android devices

前端 未结 3 1471
执笔经年
执笔经年 2021-02-03 11:42

I would like to replace the default GPS location provider on android phones with my own coordinate source.

Is there any layer/API/library/provider that would allow to b

相关标签:
3条回答
  • 2021-02-03 12:23

    Replacing the "default" is not allowed at this time and the only work around is to create a mock provider. First you must set the security permission:

    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    

    Second, set your code to use the mock provider which you will create. There is some excellent information about how to accomplish this here: http://diffract.me/2009/11/android-location-provider-mock/

    0 讨论(0)
  • 2021-02-03 12:25

    I'm pretty sure the default location providers for fine location are baked into Android.

    Given that Google are becoming more conscious about potential misuse and abuse of system resources by applications, i'd say that's a good thing. Otherwise people would be able to trick the user into thinking they're somewhere else, using the trustworthy sounding 'Use GPS satellites' setting.

    The only way I can see that you can add a location provider is via android.location.LocationManager.addTestProvider(......), which requires the permission ACCESS_MOCK_LOCATION. Now, this method and permission are both documented as being for "testing" purposes. I can't find a source that specifically says that that permission is not granted for market release apps, but I strongly suspect that to be the case.

    0 讨论(0)
  • 2021-02-03 12:41

    I'm only in the process of reading about the android SDK at the moment. However my understanding is that you would provide an implementation of a GPS_PROVIDER intent.

    Any application can then divert to using the user preferred GPS_PROVIDER intent.

    See: http://developer.android.com/guide/topics/intents/intents-filters.html

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