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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:26:51+00:00 2026-05-24T21:26:51+00:00

In my application I call requestLocationUpdates in onStart() method and I receive updates properly.

  • 0

In my application I call “requestLocationUpdates” in onStart() method and I receive updates properly.

When I turn the GPS off by calling “removeUpdate(locationlistener)” I stop receiving updates as expected.

The problem is that when I want to restart the GPS system by calling “requestLocationUpdates” method again it isn’t working! It never enters the “onLocationChanged” or “onStatusChanged” methods

my gpsLocationListener code;

public final LocationListener gpsLocationListener = new LocationListener() {
    public void onStatusChanged(String provider, int status, Bundle extras) {
        switch (status) {
        case LocationProvider.AVAILABLE:
            Logging.TraceMessage("GPS available again", Logging.INFORMATION, Logging.MAINACTIVITY);
            break;
        case LocationProvider.OUT_OF_SERVICE:
            Logging.TraceMessage("GPS out of service", Logging.INFORMATION, Logging.MAINACTIVITY);
            deviceSettings.gpsStatus = "2";
            break;
        case LocationProvider.TEMPORARILY_UNAVAILABLE:
            Logging.TraceMessage("GPS temporarily unavailable", Logging.INFORMATION, Logging.MAINACTIVITY);
            break;
        }
    }

    public void onProviderEnabled(String provider) {
        Logging.TraceMessage("GPS Provider Enabled", Logging.INFORMATION, Logging.MAINACTIVITY);
    }

    public void onProviderDisabled(String provider) {
        Logging.TraceMessage("GPS Provider Disabled", Logging.INFORMATION, Logging.MAINACTIVITY);
        deviceSettings.gpsStatus = "2";
    }

    public void onLocationChanged(Location location) {
        if(location == null) return;

        tempLoc.setItem(location.getLongitude(), location.getLatitude(), deviceSettings.getCurrentTime(), deviceSettings.satelliteCount, location.getSpeed());
            if (!SafeLocation.IsSafe(tempLoc) ){
            return;
        }

        deviceSettings.currX = tempLoc._x;
        deviceSettings.currY = tempLoc._y;
        deviceSettings.currSpeed = tempLoc._speed;
        deviceSettings.currValid = true;

    }
};

my removeupdates code;

if( ! deviceSettings.isprogramModeActive ){

                         if(gpsLocationListener != null){
                             try {
                                 locationManager.removeUpdates(gpsLocationListener);
                             } catch (Exception e) {
                             }                           
                         }
                         mylocatewait(30000);//30 saniye bekle
                         continue;
                    }

my request again code:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, ServerSettings.getGpsPer()*1000, 0, gpsLocationListener);
  • 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-05-24T21:26:52+00:00Added an answer on May 24, 2026 at 9:26 pm

    I solve the problem!

    I crate an call a handler from thread.

    locateHandler.sendEmptyMessage(1);
    

    I call the following code from a handler, not in the thread.

     Handler locateHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if(msg.what == 0)
                    locationManager.removeUpdates(gpsLocationListener);
                else if(msg.what == 1)
                    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, ServerSettings.getGpsPer()*1000, 0, gpsLocationListener);
            }
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I call the Application.Restart() method, the error comes up that detects whether the
Can a Silverlight application call a method in a full .NET c# class library?
If I call Application.Terminate OR Application.MaiForm.Close inside a method. the application doesn't terminate! procedure
when I call Application.Run() on a form, this command halts the program until the
I'm getting in trouble. I'm trying to emulate the call Application.Run using Application.DoEvents... this
If the user received a call during application running, how to automatically open the
I have DLL and application that will call some function in this dll. For
I have an API call in my application where I am checking the time
I am building application that required some data from iPhone's Call log(read only). The
I have a Silverlight application in which I would like to call a WCF

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.