Appcelerator的钛Android的后台位置服务后台、位置、Appcelerator、Android

由网友(无敌超拽哥)分享简介:我试图让一个应用程序,在那里,如果用户进入一个特定的区域,他将得到一个警告。这将工作,即使该应用程序是在后台。我发现Ti.App.iOS.backgroundService做就是iPhone,但如何启动后台服务在Android和如何present时,特别是经度和纬度发现本地通知样的事情。所以基本上我的问题是: - 后...

我试图让一个应用程序,在那里,如果用户进入一个特定的区域,他将得到一个警告。这将工作,即使该应用程序是在后台。

我发现Ti.App.iOS.backgroundService做就是iPhone,但如何启动后台服务在Android和如何present时,特别是经度和纬度发现本地通知样的事情。

所以基本上我的问题是: -

后台位置的机器人服务 安卓相当于localnotification 解决方案

有关背景地理Android上我用的是下面的策略。

1)在我app.js我添加包含我的地缘逻辑的Titanium.App.addEventListener

厨房水槽样品https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/app_events.js

2)然后,我创建一个ServiceIntent将触发每隔15分钟

厨房水槽样品https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/android_services.js

请注意,这service.js你打电话需要在你的android文件夹,即使你有一个Android唯一项目。

3)如果个人已经转移更多的则1KM,如果他们有它触发的应用程序事件在步骤1中定义的服务检查。

采用这种策略,调整我的服务时间和距离计算我已经能够减少我的大多数,我曾与内置的定位事件与距离滤波器的电池消耗的问题。

希望这有助于。

分享一个完整的社区项目 Android端加后台

I am trying to make an app , where if the user enters a particular region, he will get an alert. And that will work even if the app is in background.

I found Ti.App.iOS.backgroundService to do that for iphone but how to start the background service in android and how to present local notification kind thing when particular latitude and longitude is found.

so basically my questions are :-

background location service in android android equivalent for localnotification

解决方案

For background geo on Android I use the below strategy.

1) In my app.js I add an Titanium.App.addEventListener that contains my geo logic

Kitchen Sink Sample https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/app_events.js

2) I then create a ServiceIntent that fires every 15 minutes

Kitchen Sink Sample https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/android_services.js

Please note this service.js you call needs to be in your android folder, even if you have an android only project.

3) The service checks if the individual has moved more then 1KM, if they have it fires the App Event defined in step 1.

Using this strategy and adjusting my service time and distance calculation I've been able to reduce most of my battery drain issues that I had with the built in location event with distance filter.

Hope this helps.

阅读全文

相关推荐

最新文章