android 如何判断手机中是否有GPS模块设备

2024-11-27 01:38:19
推荐回答(1个)
回答1:

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