Git Product home page Git Product logo

Comments (8)

M0rph3v5 avatar M0rph3v5 commented on July 1, 2024

any ideas how we're able to pull this off?, having background scanning but turning it off somehow?

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 1, 2024

Apologies for the delay in responding. You may change the scan periods at any time by calling:

// set the duration of the scan to be 1.1 seconds
beaconManager.setBackgroundScanPeriod(1100l); 
// set the time between each scan to be 1 hour (3600 seconds)
beaconManager.setBackgroundBetweenScanPeriod(3600000l);

It is possible that the library does not think your app is in the background. You may also want to try setting the foreground scan periods to see if that has an effect.

If this does not work for you, please turn on debugging with:

beaconManager.setDebug(true);

Then attach a LogCat excerpt showing that the scan intervals do not change. A snippet of your code where you change the scan interval would be helpful, too.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 1, 2024

Accidental close.

from android-beacon-library.

M0rph3v5 avatar M0rph3v5 commented on July 1, 2024

thanks, I'll do some testing and see if it's working out. I thought it didn't pick it up, but maybe it wasn't truly in the background at that point.

from android-beacon-library.

M0rph3v5 avatar M0rph3v5 commented on July 1, 2024

With the app in the background and changing both foreground and background values the following log:

http://pastebin.com/vpMt5xen

With debugging on you can see here:

http://pastebin.com/CpLvarcD

That it doesn't pick up anything. I've validated that they're both accessing the same beaconmanager (pointer).

The following is my geofence transition service code

public class GeofenceTransitionService extends IntentService {

    public GeofenceTransitionService() {
        super("GeofenceTransitionService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Log.e("geofence", "handling geofence transition");

        // First check for errors
        if (LocationClient.hasError(intent)) {
            // Get the error code with a static method
            int errorCode = LocationClient.getErrorCode(intent);
            // Log the error
            Log.e("ReceiveTransitionsIntentService",
                    "Location Services error: " +
                            Integer.toString(errorCode));
        } else {
            int transitionType = LocationClient.getGeofenceTransition(intent);
            if (transitionType == Geofence.GEOFENCE_TRANSITION_ENTER) {
                Log.e("geofence", "entering geofence");
                BeaconManager.getInstanceForApplication(getApplicationContext()).setBackgroundBetweenScanPeriod(10000l);
                BeaconManager.getInstanceForApplication(getApplicationContext()).setForegroundBetweenScanPeriod(10000l);

            } else if (transitionType == Geofence.GEOFENCE_TRANSITION_EXIT) {
                Log.e("geofence", "exiting geofence");
                BeaconManager.getInstanceForApplication(getApplicationContext()).setBackgroundBetweenScanPeriod(3600000l);
                BeaconManager.getInstanceForApplication(getApplicationContext()).setForegroundBetweenScanPeriod(3600000l);

            }
        }
    }
}

from android-beacon-library.

M0rph3v5 avatar M0rph3v5 commented on July 1, 2024

any ideas? :)

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 1, 2024

To get your scan period changes to take effect right away, call beaconManager.updateScanPeriods();

from android-beacon-library.

M0rph3v5 avatar M0rph3v5 commented on July 1, 2024

Thanks!, seems like I missed that method.

from android-beacon-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.