public static boolean areProvidersEnabled(Context context) {
ContentResolver cr = context.getContentResolver();
String providersAllowed = Settings.Secure.getString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return providersAllowed != null && providersAllowed.length() > 0;
}
如果没有设置 那你可以提醒用户设置打开
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);