Normally Whenever you are trying to over a Number String ( "1234" ) into Number ( 1234 ), at that time if there is any white space in the number then it throws, NumberFormatException
. To avoid it always use trim()
method.
Instead of these lines,
double Hlat = Double.parseDouble(lat);
double Hlong= Double.parseDouble(lng);
Try this,
if ( !lat.trim().equals("") && !lng.trim().equals("") )
{
double Hlat = Double.parseDouble(lat.trim());
double Hlong= Double.parseDouble(lng.trim());
}