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

  • SEARCH
  • Home
  • 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 8913451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:28:04+00:00 2026-06-15T04:28:04+00:00

Details The app has a background service running when the app is started. In

  • 0

Details

The app has a background service running when the app is started. In this service, on onStartCommand() starts listening for GPS location with a parameter for passed meters between reads. Let’s say 50 meters for example. Each time a location is read the following operations occur:

  • read location is stored in a local database
  • retrieve all unsent location from the database
  • location(s) is sent to a web server
  • if sending is successful, the location(s) is deleted from the database

Now this behavior happens every time a location is read.The user might be walking which takes some time to make the 50 meters or drive fast, while many reads can be done and things might get messy in the database insert/retrieve. So one of the main requests is to have all read locations processed sequentially, as they were read. Something like: read location 1, insert it, send it… read location 2, insert it, send it.

I can’t find out a proper way to do this. As you know, the service runs in the same main thread as the app, so I definitely need to use threading to keep the UI running smooth.

I was thinking to use ExecutorService and a Executors.newSingleThreadExecutor() to which to submit new threads each time a location is read. In this way, I make sure processing is done in sequence but… I make new threads for each read, which might not be such a good thing.

What best approach would you suggest for this situation ?

  • 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-15T04:28:05+00:00Added an answer on June 15, 2026 at 4:28 am

    What I would do is remove the service and throw an IntentService every time a location is read.

    You can use requestLocationUpdates with pending intent argument, and set the pending intent argument with an intent that triggers your intent service.

    In the intentservice’s onHandleIntent you can then handle the location update. Intents are handled sequentially by intent service, and it handles them in a separate thread (and then expires).

    If you just need to consume one shot events on background, intentservice are a more compact and suitable solution.

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

Sidebar

Related Questions

Background This is only my second PyQt4 project. Developing a Windows app that has
I have an MVC3 app that has a details page. As part of that
My iPad (!!) app has a table view as the UISplitViewControllers details controller. To
My mvc3 app has the following URL: http://mysite.com/controller/details?id=56 I want to make it search
My app has a details screen like an AboutScreen. The height of all fields
My Code Igniter app has urls like this: http://servername/contexttroot/index.php/Sessions/login/ My question is, when the
In an app, I am displaying the details of the contacts using ABRecordRef .
I am developing an app whenever a user add some details the record get
i would get details from two MySQL tables tables structure as shown table:App |AppID|AppName|AppType|
In a Ruby on Rails app, we have some details which are stored as

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.