Java tutorial
//package com.java2s; import android.content.Context; import android.location.Location; import android.location.LocationManager; public class Main { /** * This method checks phone if it is able to get user's location * @param context * @return */ public static boolean testLocationServices(Context context) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location locationGPS = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); Location locationNet = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); boolean haveGPS = (locationGPS != null); boolean haveNet = (locationNet != null); return (haveGPS || haveNet); } }