Git Product home page Git Product logo

Comments (10)

davidgyoung avatar davidgyoung commented on July 19, 2024

Giulio,

Try turning on debug logging for the library with beaconManager.setDebug(true); Then run your test and capture a LogCat excerpt starting at the time you unbind from the library. Once you have that, please link to a gist of the LogCat excerpt to this thread. Please also annotate in the LogCat excerpt so I know where your service calls unbind.

Thanks,
David

from android-beacon-library.

Cromir avatar Cromir commented on July 19, 2024

Thanks for fast answer.

I can try to do this, but the problem is that this behavior is completely random. Some times happens after 4 hours application is running and others after 2 or 8 hours. By the way, tomorrow I will post my service code.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 19, 2024

Understood. Well, one way you could do it is to pipe the LogCat output to
a file, and let your app run overnight.

adb logcat > logfile.txt

Then you could search through the log, figure out where the problem
happened, and share that snippet of the log.

On Mon, Nov 3, 2014 at 5:58 PM, Cromir [email protected] wrote:

Thanks for fast answer.

I can try to do this, but the problem is that this behavior is completely
random. Some times happens after 4 hours application is running and others
after 2 or 8 hours. By the way, tomorrow I will post my service code.


Reply to this email directly or view it on GitHub
#50 (comment)
.

from android-beacon-library.

Cromir avatar Cromir commented on July 19, 2024

OK, this is my Service.

public class Collector extends Service implements BeaconConsumer, RangeNotifier {

    private void collectInfo(Context context) {
        collectBeaconsAroundInfo();
    }

    private void collectBeaconsAroundInfo() {
        BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
            BeaconManager manager = BeaconManager.getInstanceForApplication(getApplicationContext());

            // This is the pattern for iBeacon. (Code redacted by David Young)
            manager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("****** Code Redacted ********"));

            // Bind manager
            manager.bind(this);
        } else {
            BeAudience.getInstance().log("Collector -> Bluetooth is not enabled. Turn it on to discover beacons.");
        }
    }

    @Override
    public void onBeaconServiceConnect() {
        BeAudience.getInstance().log("Collector -> Beacon service connected.");

        BeaconManager manager = BeaconManager.getInstanceForApplication(getApplicationContext());

        // Set range listener
        manager.setRangeNotifier(this);

        try {
            // Start ranging
            manager.startRangingBeaconsInRegion(new Region("BeAudience", null, null, null));
        } catch (RemoteException e) {
            e.printStackTrace();

            //Unbind manager
            manager.unbind(this);
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        BeAudience.getInstance().log("Collector -> Start new acquisition...");
        collectInfo(this);
        return START_NOT_STICKY;
    }

    @Override
    public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
        BeaconManager manager = BeaconManager.getInstanceForApplication(this.getApplicationContext());
        BeAudience.getInstance().log("Collector -> Beacon found: #" + beacons.size());

        try {
            // Stop ranging
            manager.stopRangingBeaconsInRegion(region);
        } catch (RemoteException e) {
            e.printStackTrace();
        }

        //Unbind manager
        manager.unbind(Collector.this);
    }
}

Every time my service starts, the output in logcat is always this:

11-04 09:45:24.599  28640-28640/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta I/BeaconService﹕ beaconService version 2.0 is starting up
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 09:45:28.129  28640-28640/com.beintoo.audbeta I/BeaconService﹕ binding
11-04 09:45:28.139  28640-28640/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 09:45:28.139  28640-28640/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 09:45:28.139  28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 09:45:28.139  28640-28651/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 09:45:29.239  28640-28640/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 09:45:29.249  28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 09:45:29.259  28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 09:45:29.269  28640-28652/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 09:45:29.289  28640-28849/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #4
11-04 09:45:29.439  28640-28640/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 09:45:29.439  28640-28849/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 09:45:29.439  28640-28640/com.beintoo.audbeta I/BeaconService﹕ unbinding
11-04 09:45:29.449  28640-28640/com.beintoo.audbeta I/BeaconService﹕ onDestroy called.  stopping scanning
11-04 09:45:29.449  28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 09:45:29.459  28640-28640/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()

When BeaconService remains active, I obtain exactly the same log except for this line:

11-04 09:45:29.289  28640-28849/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #0

in which I obtain always 0 beacons.

Thanks

from android-beacon-library.

Cromir avatar Cromir commented on July 19, 2024

It's happened now. Following last 3 execution:

Nothing to notice here, everything is ok.

11-04 10:47:16.119  29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 10:47:19.559  29456-29456/com.beintoo.audbeta I/BeaconService﹕ beaconService version 2.0 is starting up
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta I/BeaconService﹕ binding
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 10:47:19.619  29456-29456/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 10:47:19.629  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:47:19.629  29456-29683/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:47:20.729  29456-29456/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 10:47:20.729  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:47:20.739  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:47:20.739  29456-29467/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:47:20.739   29456-6868/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #5
11-04 10:47:20.959   29456-6868/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 10:47:20.959  29456-29456/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 10:47:20.969  29456-29456/com.beintoo.audbeta I/BeaconService﹕ unbinding
11-04 10:47:20.999  29456-29456/com.beintoo.audbeta I/BeaconService﹕ onDestroy called.  stopping scanning
11-04 10:47:20.999  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:47:20.999  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()

Here starts issue: beaconService is started before my service bind it: "beaconService version 2.0 is starting up" is printed before "Start new acquisition".

11-04 10:47:49.759  29456-29461/com.beintoo.audbeta D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
11-04 10:47:51.359  29456-29456/com.beintoo.audbeta I/BeaconService﹕ beaconService version 2.0 is starting up
11-04 10:47:51.369  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 2 for LGE;Nexus 5;LPV79;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:47:51.369  29456-29456/com.beintoo.audbeta D/AndroidModel﹕ Score is 1 for LGE;Nexus 4;KOT49H;4.4.2 compared to LGE;Nexus 5;KTU84P;4.4.4
11-04 10:48:16.109  29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 10:48:19.489  29456-29456/com.beintoo.audbeta I/BeaconService﹕ binding
11-04 10:48:19.489  29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 10:48:19.489  29456-29456/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 10:48:19.489  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:48:19.489  29456-29683/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:48:20.599  29456-29456/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 10:48:20.599  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:48:20.609  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:48:20.609  29456-29467/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:48:20.619   29456-7228/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #5
11-04 10:48:20.729   29456-7228/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 10:48:20.729  29456-29456/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 10:48:20.809  29456-29456/com.beintoo.audbeta I/BeaconService﹕ unbinding
11-04 10:48:21.719  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()

And consequently in next acquisition, beaconServer doesn't start and beacon detected is 0 forever.
In Settings now I can see beaconService running.

11-04 10:49:19.029  29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Start new acquisition...
11-04 10:49:22.609  29456-29456/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon service connected.
11-04 10:49:22.609  29456-29456/com.beintoo.audbeta I/BeaconService﹕ start ranging received
11-04 10:49:22.609  29456-29456/com.beintoo.audbeta I/BeaconService﹕ Adjusted scanStopTime to be Tue Nov 04 10:48:21 CET 2014
11-04 10:49:23.609  29456-29456/com.beintoo.audbeta D/Callback﹕ attempting callback via intent: ComponentInfo{com.beintoo.audbeta/org.altbeacon.beacon.BeaconIntentProcessor}
11-04 10:49:23.629  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()
11-04 10:49:23.629  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ startLeScan(): null
11-04 10:49:23.649  29456-29468/com.beintoo.audbeta D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
11-04 10:49:23.659   29456-7317/com.beintoo.audbeta I/BeAudience﹕ Collector -> Beacon found: #0
11-04 10:49:23.789  29456-29456/com.beintoo.audbeta I/BeaconService﹕ stop ranging received
11-04 10:49:23.789   29456-7317/com.beintoo.audbeta D/BeaconManager﹕ Unbinding
11-04 10:49:24.759  29456-29456/com.beintoo.audbeta D/BluetoothAdapter﹕ stopLeScan()

Thanks
Giulio

from android-beacon-library.

Cromir avatar Cromir commented on July 19, 2024

Problem solved.
Every time device was connected/disconnected to a cable, BeaconService restarts.

Thanks for your time.
Giulio

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 19, 2024

Giulio, are you using the RegionBootstrap class? If so, this would cause the behavior you mention.

from android-beacon-library.

Cromir avatar Cromir commented on July 19, 2024

Actually no.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 19, 2024

Looking more at this issue, it appears that the onBeaconServiceConnect() callback is not made in step 4 if the following sequence occurs:

  1. application binds to service (service starts)
  2. application unbinds from service (service stops)
  3. charger connected/disconnected (service starts)
  4. application binds to service

A solution to this is to update the BeaconManager to set the connection to the beacon service to null in step 2, and then recreate it in step 4, thereby ensuring a callback.

Attempted fix in 27d48f66a31598a375397ad8fc1b7aed20d03e48

from android-beacon-library.

davidgyoung avatar davidgyoung commented on July 19, 2024

@Cromir, this fix has been put in the 2.1 beta releases if you would like to see if this resolves your issue.

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.