yp25 / little-fluffy-location-library

Automatically exported from code.google.com/p/little-fluffy-location-library
0 stars 0 forks source link

LocationBroadcastService keeps running infinitely when LocationService is turned off #28

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Disable Location support .

What is the expected output? What do you see instead?

- The service should have terminated seeing that there is no available 
providers Instead that background service keeps running infinitely.

What version of the product are you using? On what operating system?

- Version v17, android 4.4

I suppose, the service should timeout, if it doesn't receive callback from 
location service if a pre-defined time ( say 5 minutes) has elapsed.

Original issue reported on code.google.com by kinshuk1...@gmail.com on 30 Dec 2014 at 10:57

GoogleCodeExporter commented 9 years ago
  It seems that for Fused Provider, timeout is never handled. This works for me

<code>
    public boolean forceLocationUpdate() {
           ..........
        if (LocationLibraryConstants.SUPPORTS_GINGERBREAD) {
            if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()) == ConnectionResult.SUCCESS) {
                if (LocationLibrary.showDebugOutput) Log.d(LocationLibraryConstants.TAG, TAG + ": Force a single location update using Google GMS Location, as current location is beyond the oldest location permitted");
                mLocationClient.connect(); // this will cause an onConnected() or onConnectionFailed() callback
                //TODO: Find better solution.  Force Stop Service after 5 minutes. 
                new Timer().schedule(new TimerTask(){
                    public void run(){
                        mLocationClient.disconnect();
                        stopSelf();
                    }}, 5 * 60000);
            return true;

</code>

Original comment by kinshuk1...@gmail.com on 1 Jan 2015 at 3:40