android开发 怎么检测手机是否有GPS

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);
    }
posted @ 2012-01-11 09:56  千禧牛  阅读(706)  评论(0)    收藏  举报