According API documentation a device owner app can modify a few \"secure settings\" and specially the LOCATION_MODE with the following call :
devicePolicyMan
Solution is simply to use the String representation of the int value.
For instance to enable "gps only" location mode :
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (dpm.isDeviceOwnerApp(context.getPackageName())) {
ComponentName componentName = new ComponentName(context, MyDeviceAdmin.class);
dpm.setSecureSetting(componentName, Settings.Secure.LOCATION_MODE, String.valueOf(Settings.Secure.LOCATION_MODE_SENSORS_ONLY));
}
[Thanks to @Selvin comment]
It make sense, because when digging into javadoc for LOCATION_MODE, you can read :
Note that internally setting values are always stored as strings[...]