getlat
and getlon
may be null, and therefore not throw an exception
. You should replace your try/catch
with a if
statement which checks for null
.
Furthermore the real problem of you NullPointerException
is:
Log.d(to_lat, to_lon);
Log.d
should be used with the TAG
as first param, and the String
as second:
Log.d("LOCATION", "From " + to_lat + ", to " + to_lon);
If to_lat
and to_lon
are null
:
log.d(null, null);
will definately cause a crash.