Delphi android geolocation

问题描述 投票:0回答:0

我为商业企业写了一个android地理围栏应用程序,并将其全部放入我发送到前台的服务中,以在进入特定的封闭边界时触发业务检测通知。

感谢我发送到前台的服务,即使在应用程序关闭和手机锁定屏幕的情况下,它也能很好地工作。

前台服务代码是:


var
    LBuilder: JNotificationCompat_Builder;
    MyNotification: TNotification;
begin
    if FNotificationChannel = nil then CreateNotificationChannel;
    JavaService.stopForeground( True );
    LBuilder := TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context,     TAndroidHelper.Context.getPackageName );
    LBuilder.setAutoCancel( True );
    LBuilder.setContentTitle( StrToJCharSequence( 'GeoLocation' ) );
    LBuilder.setContentText( StrToJCharSequence( 'GeoLocation in monitoraggio' ) );
    LBuilder.setSmallIcon( TAndroidHelperEx.GetDefaultIconID );
    LBuilder.setTicker( StrToJCharSequence( 'GeoLocation' ) );
    JavaService.StartForeground( 2096, LBuilder.build );

我走了很多路,通知总是发送我设置的测试范围:酒吧、超市、烟草店等。

我只有这个问题:

在服务中我使用了一个全局变量:我称之为“strpreviousname”,为了不连续触发公司检测通知,每次位置传感器发生变化并且我总是在该范围内时

但是,我已经看到,尽管设置了变量,但当我关闭应用程序和锁定手机屏幕时,通知同样开始。

就像,每次我关闭应用程序,或者关闭手机,每次服务都会重新启动,重置 strpreviousname 全局变量,从而使其再次赎回检测通知。

你碰巧知道为什么吗?

android delphi geolocation geofence
© www.soinside.com 2019 - 2024. All rights reserved.