Google nearby API background scan doesn´t work after application kill
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?
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:
- When the app runs for the first time and beacons are within the vicinity. It will automatically detect the beacons
- 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.