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 9026143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:26:53+00:00 2026-06-16T06:26:53+00:00

My application have to catch gps coordinates and send them periodically using an handler.

  • 0

My application have to catch gps coordinates and send them periodically using an handler.
Within the onCreate method I do:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 1, this);

and with that the onLocationChanged starts working.
At the end of the onCreate, I start an handler that every 2.5 seconds do some stuff.
I think this could not be the right way to achive my target, because the onLocationChanged() is not executed in a separate thread, so if the handler executes the onLocation could not be executed.
EDIT
I do not know how to concurrently manage the retrieval of GPS coordinates (how to execute the onLocationChanged).
The timer runs every 2.5 seconds a task and at the same time the onLocationChange have to set gps values that I need in the timer.
I fear that there may be problems with the onLocationChange that may not be performed at all.
I thought to use a AsyncTask, but how to execute it?

  • 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-16T06:26:54+00:00Added an answer on June 16, 2026 at 6:26 am

    Although you have edited your question still not clear to me what exactly is your concern.

    I’ll give you some background information about concurrency, and let’s see if it helps…

    What is it

    First, concurrency means a software designed to have more then one thread. That doesn’t means that more then one thread will run in simultaneous, which only happens if you have a device with more then one core. If the device only has one core, only one thread will run at a time, and the system will switch between them.

    As soon as your system is designed to have more then one thread, you must ensure that all your code (and used libraries) that are dealing with shared objects are thread safe.

    Why should I need it

    The most common reansons why you would need to use threads are:

    • You have a heavy piece of code that could be split into parts, and you have a device with more then one core. In this case, you could have a performance benefict from having two (or more) simoultaneous running threads dealing with parts of the work.
    • You have a blocking operation in your code (i.e. read from a socket). This should be moved to a separate thread to avoid blocking all your program until socket.read() returns.
    • Finally and the most commun one in Android, any long run operation (i.e. more then a couple of seconds) should be moved to a different thread from he one used by the UI (user interface), to avoid pour user experience and/or the ANR error.

    Your situation

    You refer that you are using LocationManager and an Handler. None of these classes imply using a different thread.

    LocationManager uses the callback onLocationChange() to run the code you define in the UI thread.

    Handler runs the code in the thread where the handler is assigned to. So if you created your handler in the UI thread, the handler callback will be run there as well.

    Only if you create a new Thread (or any other class that does the same) you have a real multi-thread app that requires you to be carefull with shared objects.

    Hope it helps. Let me know if you need more clarification.

    Regards.

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

Sidebar

Related Questions

I have developed an application to find the user's location using GPS. In this
In my application I have to catch the new incoming email massage notification and
I have an application which runs multiple threads. I use MadExcept to catch errors
I have a Silverlight application in which I catch certain key presses such as
I have a C# application..I continuously get a null reference exception..I manage to catch
I have a fun issue where during application shutdown, try / catch blocks are
My application have a service and an activity. Sometimes the service will send a
I have a working application which gets the GPS Long/Lat of from a BlackBerry
I have a Winforms application which is working fine.. using a BackgroundWorkerThread to manage
I have application based on this tutorial Method I use to test connection to

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.