Hello I am Hardik Patel Android developer,
i am using ‘com.estimote:proximity-sdk:1.0.3’ SDK and app work fine when it is in foreground but when i kill app or put in background then after long time it will automatically exit from beacon range even beacon is near to device. and if i restart/reinstall app then also it not detect beacon but for the same situation if i exit from beacon range and come again in beacon range it will started working.
when i used ‘com.estimote:sdk’ this will work on same case but using ‘proximity’ sdk it not work for me.
I have used foreground service to run all my login and ‘withScannerInForegroundService(notification)’ used this method as well as per mentioned in doc
Here how i use to connect
Intent notificationIntent = new Intent(this, DbTestService.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, this.getResources().getString(R.string.app_name))
.setContentTitle(this.getResources().getString(R.string.app_name))
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent);
Notification notification = builder.build();
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel channel = new NotificationChannel(this.getResources().getString(R.string.app_name), this.getResources().getString(R.string.app_name), NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription(this.getResources().getString(R.string.app_name));
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
}
startForeground(NOTIFICATION_ID, notification);
EstimoteCloudCredentials cloudCredentials =
new EstimoteCloudCredentials(appName, appToken);
this.proximityObserver =
new ProximityObserverBuilder(getApplicationContext(), cloudCredentials)
.onError(new Function1<Throwable, Unit>() {
@Override
public Unit invoke(Throwable throwable) {
Log.e("Proximity app", "proximity observer error: " + throwable);
return null;
}
})
.withEstimoteSecureMonitoringDisabled()
.withTelemetryReportingDisabled()
.withLowLatencyPowerMode()
.withScannerInForegroundService(notification)
.build();
------------------------------------------------------------------------------------------
ProximityZone zone1 = new ProximityZoneBuilder()
.forTag("green")
.inNearRange()
.onEnter(new Function1<ProximityZoneContext, Unit>() {
@Override
public Unit invoke(ProximityZoneContext proximityZoneContext) {
Log.e(TAG, "invoke: Proxomity green enter");
return null;
}
})
.onExit(new Function1<ProximityZoneContext, Unit>() {
@Override
public Unit invoke(ProximityZoneContext proximityZoneContext) {
Log.e(TAG, "invoke: Proxomity Green exit");
return null;
}
}).build();