Theoretic question.
In my app I need to create alarm at location functionality.
So user can pick location, set alarm and any time while She/He
will get closer to location alarm will trigger.
I know that I have to create Service to listen the current
location. It is obvious that I can't use GPS.
Any ideas how to figure it out if device is close to location?
I know that I still have Network location, which probably I will
use, but I afraid of that this will consume to much energy.
If there is any internal android system service which provide such
data? That I can just setup receiver.
Any ideas are welcome ;)
I suggest building on Google Play Services in order to get the product working quickly. Of course if you need to target non-Google phones, then program this manually, but only if you have to.
Play offers Geofencing apis - here are the docs:
Creating and Monitoring Geofences
PROS:
Google is constantly updating the Play sdk to optimise the features.
quick to get it working
battery efficiency
CONS:
it will not work on non-Google API devices, i.e. Kindle Fire
Upshot of all this:
if your app relies on Google Maps at all, then use the Play Geofencing.
I decided to use ProximityAlarm in Service.
Great example from this post:
Android GPS proximity alert not working
Related
I am working on ride hailing app. I am getting location in the background after every few seconds. To get location, I am using Foreground Service. It is working fine.
But on some devices, there are different types of options to control the Background power consumption. If these options are enabled then these devices will freeze/terminate may app and foreground service too.
Due to which My app will not update the location.
Is there any solution to get location or not in this case?
For further details. please have a look on this link
FurtherMore, my second question is that if I will use Google SDK for this purpose, will google handle this or not?
If I use google sdk then will google sdk be responsible to get location in each scenario or not?
I'm working on a project that uses geofencing. When user enters the geofence area a webservice call occour. After 3 days if the user doesn't start the application the system optimizes it by disable geofencing and/or network communication.
I've tried android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission that worked fine, but Google rejected the new version of the app for violating policy. Can you give me some advice what should I do to avoid battery optimalization (or to Google accept the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).
Thanks
I have written an app that monitors accelerometer events for a few months. To minimize the battery usage the app only shows a black screen with the following services:
Accelerometer events
HTTP request services to send the data based on accelerometer events (I am using the Google Volley library, is this efficient from battery usage point of view?)
My question is can I disable Google Play Service for these events (and any other services using high battery power)? Is anyway to disable all notifications to minimize the battery usage?
Any other suggestion to minimize the battery usage is welcome.
There are few phones comes without google play services. I believe disabling is not possible. If you try, it may break the phone.
Sadly there is no way stop it completely. It will always restart if you try to stop it
I am working with the Geofence API Sample application I've got it running and seems to work alright. I did make the modifications to it to use BroadcastReceiver instead of the IntentService.
But I will only get the notifications if I have some other app open that is using GPS such as Maps, or GPS Tester app.
If I don't have one of those apps open and I walk into the geofence zone nothing happens. But as soon as I launch one of them I will get the notification within a few seconds.
I ended up creating a service that forces the GPS to stay active by requesting location updates on a relatively quick interval.
While this is admittedly a poor work around for a "real" application. It worked for my purposes. In which I needed to be able to present a working proof of concept to an audience, which impeded my ability to use a geo points which were further spread out.
Even I too had a struggle with getting Geofence notification as soon I entered Geofence or Exit the one.There were always delays in notifications until I found a really nice Location Library called little-fluffy-location-library which serves my purpose.Location updates will be broadcast to your app periodically.
According the Documentation it says that:
The library works by using Froyo's passive location listener (only possible with Android 2.2 and up, hence why it works best with it), which listens to location updates requested by other apps on your phone. The most accurate location is broadcast to your app approximately every 15 minutes. If a location update hasn't been received from another app for an hour, the library forces a location update of its own.
I think you should give a try with this Library and Let me know if it works for you!!
Is it possible to launch an app depending on the user location. I want the app to start only when I enter certain location say my office. I m aware about services running in background but I dont want my app to continuously check for location and deplete the battery.
Is it possible to register for some sort of geo-fencing broadcast ?
You can Create and Monitor Geofences with a standard Google API.
However, if you want to know if you've arrived at your office, I think a better and more battery-friendly way would be to see if you're connected to the office Wifi network.