How do I check if the phone has a GPS device or not?

advertisements

I am trying to find piece of code which can tell me whether the android phone has GPS device or not? Most of the samples I am getting in search results are telling whether GPS is enabled or not. What I am interested in is whether Android phone has Physical GPS device or not?

Thanks


public boolean hasGPSDevice(Context context)
    {
    final LocationManager mgr = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
    if ( mgr == null ) return false;
    final List<String> providers = mgr.getAllProviders();
    if ( providers == null ) return false;
    return providers.contains(LocationManager.GPS_PROVIDER);
    }