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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:59:01+00:00 2026-06-17T11:59:01+00:00

I need to find the user position with a timeout, then I wrote a

  • 0

I need to find the user position with a timeout, then I wrote a code like this

  1. Start a LocationListener

    GPSLocationListener = new LocationListener() {
    
    @Override
    public void onLocationChanged(Location location) {
             _timerGPSLocation.cancel();
    }
    
    @Override
    public void onStatusChanged(String provider, int status, Bundle b) {
    }
    
    @Override
    public void onProviderEnabled(String s) {
    }
    
    @Override
    public void onProviderDisabled(String s) {
    }
    };
    
     _locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, _GPSLocationListener);
    

    `

  2. Setup a timer for the timeout

    _timerGPSLocation = new Timer();
    _timerGPSLocation.schedule( new TimerTask() {
    
    @Override
    public void run() {
        _locationManager.removeUpdates(_GPSLocationListener);
    }
    
    }, (long)(timeout*1000) ); 
    

I think that doing this (trying to read coordinates and setup a timer with timeout) for many times can let the GPS contact some satellites and give me the right location.
There is a better way for doing this?
Calling _locationManager.removeUpdates on the timeout will remove all contacted satellites?

EDIT:

My goal is to read the GPS at regular intervals (5 minutes). I need also to set a timeout while try to get the location using GPS read. if no location is read after the timeout I need to stop the location listener. I’ve achieved this using the code liste here.

Now my question is if removing the LocationListener because it’s go in timeout will cause the loss of the “acknowledgement” between the GPS and the satellite.

  • 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-17T11:59:02+00:00Added an answer on June 17, 2026 at 11:59 am

    Scheduling a timer would work for what you’re trying to do. Similarly you could use a handler and pass it a thread or a Looper object. As in

    Handler h = new Handler();

    h.postDelayed(Runnable r, long millis);

    With that you could also post a runnable, i.e thread or looper at a time delay to cancel location updates.

    EDIT: postDelayed is used for a runnable to run after a certain delay. postAtTime posts at a certain uptime of the program

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

Sidebar

Related Questions

I am building a custom admin extension, I need to find a user's role
I need to find out the word in an image where user has clicked.
Given a user input string, I need to find if it end with one
I need to find out the value passed into an indexer. My code (c#)
I need to ask the user for an ID Number, and then use the
:-) I have this script, which find a users position taken from the number
I would like to find the position of an Android device with respect to
I'm currently trying to solve a problem where I need to find the position
Here's a though question: I need to find out when the user double-clicked the
I am trying to create new div element and then change it`s position with

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.