如何提供自己的LocationProvider在Android? [英] How to provide your own LocationProvider on Android?

查看:257
本文介绍了如何提供自己的LocationProvider在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何提供自己的LocationProvider并将其发布到系统中, 所以其他应用程序可以获取从LocationManager一个参考吧?

Does anyone know how to provide your own LocationProvider and publish it to the system, so other apps may fetch a reference to it from the LocationManager?

推荐答案

有关开发和测试的目的,你可以实现一个模拟位置提供。您需要启用允许模拟位置,在开发人员选项,以便应用程序能看到从该供应商的位置。

For development and testing purposes you can implement a mock location provider. You need to enable "Allow mock locations" in developer options in order for applications to see locations from that provider.

对于code例子,看看GPX回放:
<一href="https://github.com/johncarpenter/Android-GPX-Mock-Location-Provider">https://github.com/johncarpenter/Android-GPX-Mock-Location-Provider

For a code example, look at GPX Playback:
https://github.com/johncarpenter/Android-GPX-Mock-Location-Provider

在code登记位置提供启动文件的203行 安卓/ src目录/ COM / twolinessoftware /安卓/ PlaybackService.java

The code for registering the location provider starts in line 203 of file android/src/com/twolinessoftware/android/PlaybackService.java.

如果你想有一个真实的位置提供(如部署作为最终用户应用程序的一部分,你的功能),有消息说不能这样做,除非那提供商与系统密钥签名一个包,所以你倒是有从源代码构建自己的ROM,用你的密钥进行签名,使用相同的密钥签署您的位置提供商和手机上同时安装。

If you want a "real" location provider (e.g. to deploy your functionality as part of an end-user application), some sources say it cannot be done unless that provider is in a package signed with the system key, so you'd have to build your own ROM from source, sign it with your key, sign your location provider with the same key and install both on your phone.

然而,Android的在某个时候推出的非捆绑位置提供者。显然,他们需要的是,为了从Android内核到谷歌应用服务包将自己的NetworkLocationProvider。

However, Android at some point introduced "unbundled" location providers. Apparently they needed that in order to move their own NetworkLocationProvider from the Android core into the Google Apps package.

我还没有看到一个未捆绑的位置提供在实践工作尚未我不使用它知道任何开源$ C ​​$ C,但它看起来像最新版本的Andr​​oid有售后位置提供支持

I haven't seen an unbundled location provider working in practice yet and I'm not aware of any open-source code using it, but it looks like recent version of Android have support for "aftermarket" location providers.

来源$ C ​​$ c代表各自的图书馆是
<一href="https://github.com/CyanogenMod/android_frameworks_base/tree/cm-10.1/location/lib">https://github.com/CyanogenMod/android_frameworks_base/tree/cm-10.1/location/lib

Source code for the respective library is at
https://github.com/CyanogenMod/android_frameworks_base/tree/cm-10.1/location/lib

一个位置,供应商将不得不延长 com.android.location.provider.LocationProviderBase

A location provider would have to extend com.android.location.provider.LocationProviderBase.

类和方法都记录在code。

Classes and methods are documented in the code.

编辑:纵观
<一href="https://github.com/android/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml">https://github.com/android/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml
起始于线607,它看起来像保护级别 INSTALL_LOCATION_PROVIDER 权限 signatureOrSystem 。这意味着任何应用程序,它使用此功能(即安装位置提供,不一定是locaion提供者本身),要么需要以相同的密钥为平台签署(这需要你从源代码构建一个完整的Andr​​oid系统)或者安装为系统应用程序(这可能工作植根设备)。

Looking at
https://github.com/android/platform_frameworks_base/blob/master/core/res/AndroidManifest.xml
starting at line 607, it looks like the protection level for the INSTALL_LOCATION_PROVIDER permission is signatureOrSystem. This means that any app which uses this feature (i.e. installs a location provider, not necessarily the locaion provider itself) would either need to be signed with the same key as the platform (which would require you to build your entire Android system from source) or be installed as a system application (which might work on rooted devices).

有一些code在
https://github.com/microg/NetworkLocation
这似乎实现一个LocationProvider。我没有看它的细节(还)或建造它,所以我不能说,如果它的工作原理是什么requierd它。但也许它提供了一些三分球。

There is some code at
https://github.com/microg/NetworkLocation
which seems to implement a LocationProvider. I haven't looked at it in detail (yet) or built it, so I cannot say if it works and what is requierd for it. But maybe it provides some pointers.

这篇关于如何提供自己的LocationProvider在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆