Closed HAmatrook closed 6 years ago
I'm not an Indoor SDK expert, but error message clearly tells that you that in line 138 (in method onStart
) startPositioning
was called on null object reference. When you look at that line it is obvious that indoorLocationManager
must be null . Next step is to check where indoorLocationManager
is initialized and it seems that it is inside getLocation
callback. This request looks like it is asynchronous cloud request. So now it is clear what happens:
onCreate
asynchronous call is made to CloudonStart
methods is called (as Activity lifecycle diagram says)NullPointerException
is thrown becasue indoorLocationManager
is nullindoorLocationManager
(but is too late)
In other words onStart
gets called before Cloud call has finished and finds indoorLocationManager
set to null, becuase it is initialized when callback ends.
Solution will be to call startPositioning
after callback finishes.
I wander why call to indoorLocationManager
is guarded for null inside onStop
, but not inside onStart
?
I needed to look at the code to find why this is happening, but if you already have your Android Studio running, the simplest method is to run your code in debug mode and place one breakpoint in line where NPE happens and second one in line where variable is initialized or cleared. Then run the code and see in which line program stops first.
Prerequisites
Basic information
Estimote SDK version: [com.estimote:indoorsdk:2.3.0]
Android devices affected: [HUAWAEI P smart]
Android OS version affected: [Oreo 8.0.0]
Beacon hardware version: [F3.3]
Description
[forced close if I run the activity]
Steps to reproduce: I did not get it
Expected behavior: [View the map with the user position]
Actual behavior: [Forced close]
(Optional) Additional information