将 android gps 位置更新持续存储和发送到 Web 服务器的最佳方法
Best approach to store and send android gps location updates continously to a webserver
我正在制作一个移动应用程序来跟踪管理设备上的目标设备位置。为此,我将位置更新存储在 PHP-MySQL 服务器中,然后在管理设备上获取并显示它。
为此,目标设备不断更新 MySQL 数据库中的位置 table。管理设备不断获取位置 table 数据。
是否有任何其他方法可以减少 MySQL 数据库的流量并仅使用 PHP 将位置更新直接发送到管理设备?
I just want to know if there is some way to send location updates
directly to the other android device, without saving them in web
database.
如果您不关心将每个位置存储在数据库中,那么您可以使用某种内存队列来保存位置并使用 GCM 将它们发送到管理设备。
检查此 link https://developers.google.com/cloud-messaging/android/client 以了解如何在 android 上设置 gcm ;)
您的服务器会执行如下操作:
- 接收者 POST 有新位置
- 将位置添加到队列
- 将 GCM 消息发送到具有新位置的管理设备
发送连续的位置更新会耗尽电池电量并消耗大量数据。相反,将请求捆绑在一起。考虑使用 SyncAdapter
定期向您的服务器发送一堆数据。
The sync adapter component in your app encapsulates the code for the
tasks that transfer data between the device and a server.
SyncAdapter
为您做了很多繁重的工作和错误处理。例如,如果您因为网络故障而无法发送位置信息,会发生什么情况?它为您处理。
我正在制作一个移动应用程序来跟踪管理设备上的目标设备位置。为此,我将位置更新存储在 PHP-MySQL 服务器中,然后在管理设备上获取并显示它。 为此,目标设备不断更新 MySQL 数据库中的位置 table。管理设备不断获取位置 table 数据。
是否有任何其他方法可以减少 MySQL 数据库的流量并仅使用 PHP 将位置更新直接发送到管理设备?
I just want to know if there is some way to send location updates directly to the other android device, without saving them in web database.
如果您不关心将每个位置存储在数据库中,那么您可以使用某种内存队列来保存位置并使用 GCM 将它们发送到管理设备。
检查此 link https://developers.google.com/cloud-messaging/android/client 以了解如何在 android 上设置 gcm ;)
您的服务器会执行如下操作:
- 接收者 POST 有新位置
- 将位置添加到队列
- 将 GCM 消息发送到具有新位置的管理设备
发送连续的位置更新会耗尽电池电量并消耗大量数据。相反,将请求捆绑在一起。考虑使用 SyncAdapter
定期向您的服务器发送一堆数据。
The sync adapter component in your app encapsulates the code for the tasks that transfer data between the device and a server.
SyncAdapter
为您做了很多繁重的工作和错误处理。例如,如果您因为网络故障而无法发送位置信息,会发生什么情况?它为您处理。