getApplicationContext() on a null object reference
public class Distance extends Application
Do not randomly extend classes, just because you think that it will clear up a compiler error. You do not have a valid Application
subclass here, and you are not using it properly.
Step #1: Remove extends Application
from Distance
.
Step #2: Have getDistance()
take a Context
as a parameter, and have it use that with MySingleton
Step #3: Have MainActivity
pass getApplicationContext()
into getDistance()
as the Context