Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7804195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:50:06+00:00 2026-06-02T01:50:06+00:00

I developing an app which tracks a user via GPS and reminds them if

  • 0

I developing an app which tracks a user via GPS and reminds them if they cross a toll bridge.

I obviously need the GPS location listener to run in a service and I’ll also need a partial-wakelock so it can run occasionaly when the phone is asleep.
I also want the GPS updates to vary in frequency depending on the distance from the toll bridge to save battery.
The cwac- WakefulIntent service seems ideal for what I’m trying to achieve.

However, there are a couple of problems I can see me having before I head down this route (if you pardon the pun ;-).

Does the WakefulIntent service exit and release the wakelock once doWakefulWork() completes even if I’m waiting for my locationlistener to return some GPS updates.

How can I prevent doWakefulWork for returning until I get a location update and cleanup my listener.

What happens if I’m still waiting for a GPS update when alarm manager starts the service again, i.e. before doWakefulWork() has completed?

How can I persist data between instanciations of the service. Can I stuff an array of GPS co-ords into SharedPrefs?

Finally, as I get closer to a toll bridge I need more GPS frequent updates. Do I manage that within doWakefulWork() or by altering scheduleAlarms() so that it uses setRepeating() with a number of minutes stored in SharedPrefs by the service. The idea here is to throttle GPS usage based on proximity to an area of interest.

While the demo app provides a template to work from, I haven’t been able to find any solid examples of WakefulIntentService doing any asynchronous jobs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:50:08+00:00Added an answer on June 2, 2026 at 1:50 am

    The cwac- WakefulIntent service seems ideal for what I’m trying to achieve.

    Not really. IntentService is not good for location tracking, because you cannot register a listener. The service will shut down once onHandleIntent() ends.

    Personally, I would use addProxmityAlert() on LocationManager, rather than mess with any of this yourself.

    Does the WakefulIntent service exit and release the wakelock once doWakefulWork() completes even if I’m waiting for my locationlistener to return some GPS updates.

    Yes.

    How can I prevent doWakefulWork for returning until I get a location update and cleanup my listener.

    You don’t. You use something else, such as LocationPoller, or, better yet, addProximityAlert().

    What happens if I’m still waiting for a GPS update when alarm manager starts the service again, i.e. before doWakefulWork() has completed?

    You ensure that you have appropriate timeout logic in place to prevent this, such as can be found in LocationPoller.

    How can I persist data between instanciations of the service. Can I stuff an array of GPS co-ords into SharedPrefs?

    Yes, or a database, or a file in a format of your choosing.

    Finally, as I get closer to a toll bridge I need more GPS frequent updates. Do I manage that within doWakefulWork() or by altering scheduleAlarms() so that it uses setRepeating() with a number of minutes stored in SharedPrefs by the service.

    You would change your alarm schedule.

    I haven’t been able to find any solid examples of WakefulIntentService doing any asynchronous jobs.

    WakefulIntentService is the “asynchronous job”. It does not execute other asynchronous jobs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im developing a app which has a user sign-up activity, there I need to
I am developing an app which uses gps. i need a high accuracy so
I am developing an app which allows the user to customise every component such
I'm developing the app which has input fields and whenever user enters the controll,
I'm currently developing an app which uses GPS location on googleMaps view. I check
I am new to iPhone development .Need help.I am developing iPhone app which contain
I am developing an app in which I need a ListView whose rows have
Im developing an App which is going to be used on Samsung Galaxy SII
I'm developing an app which has a large amount of related form data to
I am developing an app which requires the phone to ring or make some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.