简体   繁体   中英

Android geofencing not working as a service

I tried making my first geofencing app following google's tutorial and this tutorial http://www.coderzheaven.com/2016/06/20/geofencing-in-android-a-simple-example/ It works great when the app is open, but when I close the app I get no notification. So I tried running just the tutorial code and it had the same problem. However I noticed that when my app was running(which implemets geofencing the same way) and the tutorial was closed the tutorial's service worked becuase I got the notification from the tutorial.(Same thing if the tutorial was open and my app closed) What is wrong with the tutorial code?

Intent service used in the mentioned example works good if your app is in foreground but when the app is in background, this IntentService is never called.So we need to use Broadcast-Receiver instead of Intent service.

I found this blog helpful in getting solution.

http://davehiren.blogspot.in/2015/01/android-geofence-stop-getting.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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