Beacon not detect after long time

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();

I have this problem too! Did you have solution?

Does this happen on Android 7.x by any chance? For a short time, Android 7.x introduced a 30-minute restriction on Bluetooth scanning, which means you essentially have to restart the scanning every 30 minutes. That restriction was later removed in Android 8.0 for hardware-filtered scans (which Proximity SDK uses, and which most (probably all?) modern Android smartphones support).

I’ve tested proximity scanning in android 8 and 9 and also found that proximityObserver stop scanning after long period of time. The following code is in onStartCommand and the service has startForeground(…)

        val estimoteMessageListener = EstimoteMessageListener(this.applicationContext)
        val proximityObserver = ProximityObserverBuilder(this, (this.applicationContext as ConnectApplication).cloudCredentials)
                .withTelemetryReportingDisabled()
                .withEstimoteSecureMonitoringDisabled()
                .onError { throwable ->
                    Log.e("app", "proximity observer error: $throwable")
                }
                .withBalancedPowerMode()
                .build()

        val zone = ProximityZoneBuilder()
                .forTag("vorrarit-pakgon-com-s-prox-o3h")
                .inCustomRange(20.0)
                .onContextChange { contexts ->
                    estimoteMessageListener.onContextChange(contexts)
                }
                .build()
        proximityObserverHandler = proximityObserver.startObserving(zone)