
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);
}

有些机器还真没有GPS模块。。。今天还真让我遇上了。
还是在程序里加入检测把,比如我的程序是强退了,用户体验太差了。。。