title: Android 6, set global settings WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN
body: <p>With Android 6, I would like to set the global setting <code>WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN</code> and this is what I've done:</p>
  
  <pre><code>mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
  deviceAdminComponentName = new ComponentName(this, MyDeviceAdminReceiver.class);
  try {
      Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
      intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,deviceAdminComponentName);
      intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,"Your boss told you to do this");
      startActivityForResult(intent, ACTIVATION_REQUEST);
  
  }catch (Exception e){
      Logg.d("Error: " + e.getMessage());
  }
  </code></pre>
  
  <p>where MyDeviceAdminReceiver is a class that extends DeviceAdminReceiver.</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  switch (requestCode) {
      case ACTIVATION_REQUEST:
          if (resultCode == Activity.RESULT_OK) {
  
              try {
                  mDevicePolicyManager.setGlobalSetting(deviceAdminComponentName, Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, "1");
  
               }catch (Exception e){
                  Logg.e("Error " + e.getMessage());
               }
  
          } 
          return;
      }
      super.onActivityResult(requestCode, resultCode, data);
  }
  
  
  &lt;receiver android:name=".MyDeviceAdminReceiver" android:permission="android.permission.BIND_DEVICE_ADMIN"&gt;
      &lt;meta-data android:name="android.app.device_admin"
                android:resource="@xml/device_admin_sample" /&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  
  &lt;device-admin xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;uses-policies&gt;
          &lt;limit-password /&gt;
          &lt;watch-login /&gt;
          &lt;reset-password /&gt;
          &lt;force-lock /&gt;
          &lt;wipe-data /&gt;
          &lt;expire-password /&gt;
          &lt;encrypted-storage /&gt;
          &lt;disable-camera /&gt;
          &lt;set-global-proxy/&gt;
          &lt;disable-keyguard-features/&gt;
      &lt;/uses-policies&gt;
  &lt;/device-admin&gt;
  </code></pre>
  
  <p>Unfortunately, when running the previous code I always get a Security exception when executing <code>mDevicePolicyManager.setGlobalSetting</code></p>
  
  <pre><code>java.lang.SecurityException: Admin ComponentInfo{com..../com....MyDeviceAdminReceiver} does not own the device
  at android.os.Parcel.readException(Parcel.java:1627)
  at android.os.Parcel.readException(Parcel.java:1579)
  at android.app.admin.IDevicePolicyManager$Stub$Proxy.setGlobalSetting(IDevicePolicyManager.java:7150)
  at android.app.admin.DevicePolicyManager.setGlobalSetting(DevicePolicyManager.java:4558)
  at ....WifiScanActivity.onActivityResult(WifiScanActivity.java:152)
  at android.app.Activity.dispatchActivityResult(Activity.java:6490)
  at android.app.ActivityThread.deliverResults(ActivityThread.java:3794)
  at android.app.ActivityThread.handleSendResult(ActivityThread.java:3841)
  at android.app.ActivityThread.access$1400(ActivityThread.java:154)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:224)
  at android.app.ActivityThread.main(ActivityThread.java:5526)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>Any ideas?</p>