java 如何创建一个实时位置共享Android应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43909006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 07:49:20  来源:igfitidea点击:

How to create a real time location sharing android app

javaandroidgoogle-mapsgeolocationandroid-gps

提问by iyashwant

I want to create an app where people can see where they and their friends are Eg: - imagine 2 people are using the app they should be able to see each other's location in real time and they should be able to navigate to each other Can someone help me get the resources for creating such an app

我想创建一个应用程序,人们可以在其中看到他们和他们的朋友在哪里 例如: - 想象 2 个人正在使用该应用程序,他们应该能够实时查看彼此的位置,并且他们应该能够相互导航帮助我获取创建此类应用程序的资源

回答by Aman Jain

Building real-time location sharing app requires two major things:

构建实时位置共享应用程序需要做两件事:

  • Google Fused Location API (On Device Side)
  • A two-way communication channel between device and server.
  • Google Fused Location API(在设备端)
  • 设备和服务器之间的双向通信通道。

Using above those in parallel to generate location data and send it to the server needs to be a fine balance between accuracy and battery drain.

并行使用以上那些来生成位置数据并将其发送到服务器需要在准确性和电池消耗之间取得良好的平衡。

You can use the HyperTrackSDK to build real-time location sharing feature in few steps.

使用HyperTrackSDK 只需几步即可构建实时位置共享功能。

Step 1

步骤1

Follow setupguide to integrate HyperTrack SDK

按照设置指南集成 HyperTrack SDK

Step 2

第2步

Use SDK methodHyperTrack.createAndAssignActionusing lookupIDand expectedPlaceto generate location sharing tracking URL to share with your friend.

使用 SDK方法HyperTrack.createAndAssignAction使用lookupIDexpectedPlace生成位置共享跟踪 URL 与您的朋友分享。

Using tracking URL your friends can track you.

使用跟踪 URL,您的朋友可以跟踪您。

Step 3

第 3 步

On the other end you can fetch tracking detail from tracking URL to create another action to share your friend location using the same lookupIDand expectedPlaceand to fetch the lookupIDand expectedPlace, call SDK methodHyperTrack.getActionsForLookupIdand repeat Step 2.

在另一端,您可以从跟踪 URL 获取跟踪详细信息,以创建另一个操作以使用相同的lookupIDand共享您的朋友位置expectedPlace并获取lookupIDand expectedPlace,调用 SDK方法HyperTrack.getActionsForLookupId并重复步骤 2。

Step 4

步骤4

Now to see the updated location in google map layout on your phone, you can integrate Live Tracking Viewprovided by SDK. After integration happens, call HyperTrack.trackActionByLookupIdmethodusing the same lookupID to see the real-time updating location of your friends.

现在要在手机上查看 google 地图布局中更新的位置,您可以集成SDK 提供的实时跟踪视图。整合完成后,使用相同的lookupID调用HyperTrack.trackActionByLookupId方法查看好友的实时更新位置。

You can also refer to the implementation of live location sharing feature hereand we have open-sourced our live location sharing app https://github.com/hypertrack/hypertrack-live-android.

您也可以在这里参考实时位置共享功能的实现,我们已经开源了我们的实时位置共享应用程序https://github.com/hypertrack/hypertrack-live-android

Feel free to ask anything.

随意问任何事情。

enter image description here

在此处输入图片说明

Disclaimer: I was an engineer of HyperTrack.

免责声明:我是 HyperTrack 的工程师。

We have worked hard to make the SDK battery efficient and accurate without compromising on realtime-ness of the locations data. In case of issue, we provide any kind of technical supportrequired during and after integration.

我们努力使 SDK 电池高效且准确,同时不影响位置数据的实时性。如果出现问题,我们会在集成期间和之后提供所需的任何类型的技术支持

回答by Alex Shutov

Get location of user and send it to Firebase. All users, subscribed to changes of that field in Firebase will be notified at the time of update or as soon as they get Internet connection.

获取用户的位置并将其发送到 Firebase。所有订阅 Firebase 中该字段更改的用户都将在更新时或在获得 Internet 连接后立即收到通知。

回答by Dhaval Solanki

If you want to develop this type of application then need to understand all of following point:

如果您想开发此类应用程序,则需要了解以下所有要点:

Location API- You need to understand about location api which will provide you live location data using combination of cell tower data or Wifi Signal and GPS, Fusion Location api is the good one as per my understanding, another also available,

位置 API- 您需要了解位置 api,它将使用蜂窝塔数据或 Wifi 信号和 GPS 的组合为您提供实时位置数据,据我所知,Fusion Location api 是最好的,另一个也可用,

API for Live live update- You need to configure API or mechanism which update live location on your server or friend. As per my concern if you use socket for that is good other wise also you can firebase as the best one,

用于实时更新的 API- 您需要配置 API 或机制来更新您的服务器或朋友上的实时位置。根据我的担忧,如果你使用套接字是好的,否则你也可以将 firebase 作为最好的,

List of application which like this- Life360, GeoZill, e.t.c,

像这样的应用程序列表- Life360、GeoZill 等,