Android Location Manager cant fetch the location ? -
using sort of code location of current gps positon ...
public double[] showcurrentlocation() { double[] gps = new double[2];; try { location location = locationmanager .getlastknownlocation(getbestprovider()); if (location != null) { gps[0] = (location.getlatitude()); gps[1] = (location.getlongitude()); log.d("-------------- >>> latitude", "--"+gps[0]); log.d("-------------- >>> longitude", "--"+gps[1]); } } catch (exception e) { toast.maketext(context, "enable location", toast.length_long) .show(); } log.d("-------------- >>> latitude", "--"+gps[0]); log.d("-------------- >>> longitude", "--"+gps[1]); return gps; } public string getbestprovider() { locationmanager = (locationmanager) context .getsystemservice(context.location_service); criteria criteria = new criteria(); criteria.setpowerrequirement(criteria.no_requirement); criteria.setaccuracy(criteria.no_requirement); string bestprovider = locationmanager.getbestprovider(criteria, true); return bestprovider; }
but not getting value instead catch block printing "enable location" here ...
need immediate help.
Comments
Post a Comment