Problem with Proximity Observer and background monitoring


#1

Hi.

I am using Android Proximity SDK to create a plugin for Unity3D. The plugin looks for beacons on background with a permanent notification. Everything works as it should until I try to stop the background service in the OnDestroy method using Android’s Task Manager.
The service stops, it no longer check for beacons and the notification disappears. But the notification appears again, just the notification. That is a problem when I try to open the app again, the app crashes and throws this exception.

java.lang.Error: FATAL EXCEPTION [main]
Unity version : 2017.4.0f1
Device model : motorola Moto G (5) Plus
Device fingerprint: motorola/potter_n/potter_n:7.0/NPNS25.137-92-10/12:user/release-keys

Caused by: java.lang.RuntimeException: Unable to start service com.estimote.scanning_plugin.packet_provider.service.PacketProviderWrapperService@57ee47e with Intent { cmp=com.eleven.ProyectoLocacionCC/com.estimote.scanning_plugin.packet_provider.service.PacketProviderWrapperService (has extras) }: kotlin.UninitializedPropertyAccessException: lateinit property serviceHelper has not been initialized
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3335)
    at android.app.ActivityThread.-wrap21(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1578)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6123)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
 Caused by: kotlin.UninitializedPropertyAccessException: lateinit property serviceHelper has not been initialized
    at com.estimote.scanning_plugin.packet_provider.service.PacketProviderWrapperService.showNotification(PacketProviderWrapperService.kt:82)
    at com.estimote.scanning_plugin.packet_provider.service.PacketProviderWrapperService.onStartCommand(PacketProviderWrapperService.kt:32)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3318)
    at android.app.ActivityThread.-wrap21(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1578) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6123) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

I don’t know what to do about it. I would like help about it.

Thanks