Background Location services for android - android

I have an android app that I am developing and I need to have a Service running that checks the user's location at a defined interval.
I've found other posts and Google's documentation, but I found them all very confusing, where people are saying different things.
If someone could please help me on this, I would really appreciate it :)

All you need to do create repetitive alarm using alarm manager.
https://developer.android.com/training/scheduling/alarms.html

Related

Create schedule save data in android service based on system time

I want create app android run something in service and repeat after 1 hours but it based on the system clock, 01:00,02:00,.... So, What I have to do? AlarmManager? please help me. thanks all.
Yes, AlarmManager is a decent option. You may also look at JobScheduler as another option. For more details on the ins and outs of using AlarmManager, see this article.

Do something at a certain time of day in an android app

I'm writing a reminder app for Android where users can create custom notifications that will appear at a time of the day that they specify. I realize that there is another similar question, but the only answer was to use the AlarmManager, which, according to the documentation, resets when the device is rebooted. I want the user to be able to set a notification to appear at a certain time on a certain date, meaning that it should retain the information through a reboot.
Ultimately though, the app needs to be notified that it needs to do something.
Eventually, I would also like to have the same behavior when the device reaches a certain location, if you have any thoughts on that. :)
Bear with me, I'm a bit of a novice programmer (I'm 17).
Thanks in advance.
The commentors are correct: you will need to use an AlarmManager to create your alarm and you will need a boot receiver to handle resetting your alarm after a reboot.
GeoLocation and GeoFences are pretty easy. I have an example app here: https://github.com/androidfu/GeofenceExample
You're not going to care about the mock location bits in that example unless you wish to test entering and exiting your target location, but the rest of the code should work for what you need.
Also, GeoFences do not persist a reboot either so it'll be good for you to get familiar with your on-boot receiver ;) You'll want to re-add your GeoFence after a reboot too.

Not receiving the broadcast while running the LocationPollerDemo

I've searched through a number of the questions and answers in regards to the LocPoller from Commonsware and haven't found the answer to my problem. I have tried using the demo of the latest from github and I'm having issues. First I must admit that I modified the PERIOD in the demo so the alarm fires every 15 seconds. I realize this will be a large drain on the batter and it's just for testing. I would expect that the LocationReceiver's onReceive() would be called ever 15 seconds but that isn't happening.
Debugging things I see that the alarm is triggering and everything seems good in that it's getting to the PollerThread and calling sendBroadcast. So I assume I have something setup wrong, but I'm not sure what. Other than changing the PERIOD in the demo everything else is as is. I've tried running this on a device and emulator (Level 8). Any help in debugging this would be appreciated.
In the end the functionality I'm looking for is to have the ability to keep track of a phones location so at any point my app can get the current location. I saw this in my research and though it fit the bill perfect. If someone has a better idea of different approach I'd love to hear it.
Thanks,
Rindress
In the end the functionality I'm looking for is to have the ability to keep track of a phones location so at any point my app can get the current location. I saw this in my research and though it fit the bill perfect.
No, it is not.
If someone has a better idea of different approach I'd love to hear it.
Step #1: Call requestLocationUpdates() when you want to start receiving location updates in your app
Step #2: Use the location fixes delivered to your LocationListener, or call getLastKnownLocation(), as needed
Step #3: Call removeUpdates() when you no longer want to receive location updates in your app

use of ntp service

I'm developing an app that needs to control real time in any location on the Earth and do something when time comes. At the same time not to rely on system time because user can easily change it.
Does anybody have an experience of implementing "sntp/ntp" service on android device or is there any other solution to do it?
Thanks
Check out the SNTP client code at:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/net/SntpClient.java

Android scheduling or timer APIme

Pardon me if m asking some discussion based questions. I am completely new to android environment and I am developing an android based application wherein i need to apply some modification in messaging system for my project. therein i need to employ a timer facility for the outgoing messages where user could be able to time his message so that at that scheduled time, the sms should go automatically. I want to know which messaging API will help me in implementing so. I can sense that dis is not upto the mark question to be asked but i searched on every site but all work in vain. Hoping to get a positive reply from your side.
You should have a look at ScheduledExecutorService
i think this is what you are searching for. This service is able to execute tasks based on TimeUnits in the background.
You might also want to check out AlarmManager. You can use it to send a custom Intent at some time in the future. It might be better than other kinds of timers (depending on your situation), because it will cause the phone to wake up when the intent is delivered. Otherwise, your code might not run if the CPU is asleep.

Categories

Resources