connectivity-samples icon indicating copy to clipboard operation
connectivity-samples copied to clipboard

Google nearby API background scan doesn´t work after application kill

Open drdla49 opened this issue 9 years ago • 1 comments

I have kontakt.io beacon and I try to write application for background scanning with nearby API.

I use this method to subscribe messages:

SubscribeOptions options = new SubscribeOptions.Builder() // Finds messages attached to BLE beacons. See // https://developers.google.com/beacons/ .setStrategy(Strategy.BLE_ONLY) .build();

Nearby.Messages.subscribe(mGoogleApiClient, getPendingIntent(), options)
        .setResultCallback(new ResultCallback<Status>() {
            @Override
            public void onResult(@NonNull Status status) {
                if (status.isSuccess()) {
                    Log.i(TAG, "subscribed successfully");
                    mSubState = SubState.SUBSCRIBING;
                    // Start background service for handling the notification.
                    getActivity().startService(getBackgroundSubscribeServiceIntent());
                } else {
                    Log.i(TAG, "could not subscribe");
                    handleUnsuccessfulNearbyResult(status);
                }
            }
        });

My code is according to this sample.

I´m receiving messages correctly, but when I kill application no more message come.

Is there any way to get messages from nearby after killing application?

drdla49 avatar Apr 20 '16 07:04 drdla49

Hi! I also experienced this issue with the demo app. When the app is killed, there is no way to get the messages.

The only successful things so far for me are:

  1. When the app runs for the first time and beacons are within the vicinity. It will automatically detect the beacons
  2. The beacons are not in the vicinity and the app is running, then screen must first be closed. Then when beacons are on the vicinity, screen should be turned on. Detection happens after screen was on. So far these test cases happened when app is running.

ekahannah avatar May 03 '16 06:05 ekahannah