简体   繁体   English

创建适用于Android的位置跟踪应用:本机还是phonegap?

[英]create location tracking app for Android: native or phonegap?

We need to create an app, which works for time tracking of the employees as well as location tracking. 我们需要创建一个应用程序,该应用程序可用于员工的时间跟踪以及位置跟踪。 We only want to program it for Android, but we don't have any Android skills. 我们只想为Android编程,但没有任何Android技能。

Therefore phonegap came as a great alternative. 因此,phonegap可以作为一个很好的选择。 But there are several questions, to which I can't find a clear answer in the web. 但是有几个问题,我在网上找不到明确的答案。

  • If the phone is in standby mode, can the phonegap-app still send position data? 如果电话处于待机模式,phonegap-app仍可以发送位置数据吗? Would this still be phonegap standard or do I need to use plugins? 这仍然是phonegap标准还是我需要使用插件?

  • the smartphones will be very simple and cheap. 智能手机将非常简单且便宜。 Is there a higher risk, that the phonegap application gets closed by Android to free memory then for a native app? 是否存在较高的风险,即Phonegap应用程序被Android关闭以释放内存,然后释放本机应用程序?

Alltogether, could it be recommend to invest the time to learn Android or would it be better to stay at our language JS? 总而言之,是否建议您花时间学习Android还是最好还是使用我们的JS语言?

It's perfectly feasible to write a location tracking application using phonegap and have it a) work in a performant manner on low spec android phones and b) keep the app running in the background when the phone is in standby mode. 使用phonegap编写位置跟踪应用程序并使其具有以下功能是完全可行的:a)在低规格的android手机上以高性能的方式工作,b)在手机处于待机模式时使应用程序在后台运行。

To keep the app running in the background on android, it's necessary to acquire a partial wakelock (see android powermanager ). 为了使应用程序在android上在后台运行,有必要获取部分唤醒锁(请参阅android powermanager )。 In phonegap, you need to use a plugin to achieve this. 在phonegap中,您需要使用插件来实现。 On the plus side, there's an existing phonegap plugin to do this. 好的方面来说,有一个现有的phonegap插件可以做到这一点。 The downside is that in order to use a custom plugin, you will not be able to use the convenient phonegap build method to build your app, so will need to do the manual process via the Eclipse IDE, but this is not a great hassle to set up (see here ). 缺点是,为了使用自定义插件,您将无法使用便捷的phonegap构建方法来构建应用程序,因此需要通过Eclipse IDE进行手动处理,但这对您来说并不是一个麻烦设置(请参阅此处 )。

In terms of your app getting closed because of android running out of memory, and also having it perform responsively on cheap, low spec devices, this won't be a problem so long as you are careful to write your javascript code in an optimal way. 就您的应用程序由于Android内存不足而关闭,以及使其在廉价,低规格的设备上响应良好,只要您谨慎地以最佳方式编写javascript代码,这将不是问题。 I've implemented a location tracking app using phonegap which uses custom maps and in testing on older android devices including HTC Desire and HTC Wildfire, performance was acceptable and the partial wakelock worked - I had no problems with the app getting closed because of lack of memory. 我已经使用phonegap实现了一个位置跟踪应用程序,该应用程序使用了自定义地图,并在包括HTC Desire和HTC Wildfire在内的较旧的android设备上进行了测试,性能可以接受,并且部分唤醒锁有效-由于缺少记忆。

I chose phonegap over native because I'm a web developer so Javascript is more convenient for me than having to start from scratch with Java and the android SDK, and also because I was able to use the same JS code base with appropriate plugins to produce the same app for iOS. 我选择phonegap而不是native,因为我是一名Web开发人员,因此Java脚本比起从头开始使用Java和android SDK更为方便,而且因为我能够使用具有适当插件的相同JS代码库来生成代码,适用于iOS的相同应用。 Phonegap is able to access GPS hardware on the device and in testing outside I found the average accuracy to be between 4 to 8 metres depending on the device. Phonegap能够访问设备上的GPS硬件,在外部测试中,我发现平均精度在4至8米之间,具体取决于设备。 Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM