title: Not able to launch device administrator activity from my service class (Android Lollipop)
body: <p>I'm trying to prompt the user with the device administrator activity to enable my application as a device administrator. And here is the code which attempts to call the device administrator activity from my service class:</p>
  
  <pre><code>ComponentName deviceAdmin=new ComponentName(context,DeviceAdminReceiver.class);
  Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
  intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin);
  intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Make sure to accept in order to provide support for lock and wipe");
  PendingIntent pendingIntent = PendingIntent.getActivity(context, DevicePolicyManagerLockWipeService.RESULT_ENABLE, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
  pendingIntent.send();
  </code></pre>
  
  <p>Android Manifest is as follows;</p>
  
  <pre><code>&lt;receiver android:name=".DeviceAdminReceiver" android:label="DeviceAdminReceiver"
  android:permission="android.permission.BIND_DEVICE_ADMIN" android:exported="true"&gt;
  &lt;meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin"/&gt;
  &lt;intent-filter&gt;
     &lt;action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/&gt;
  &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>This works perfectly on any 4.x android versions, but doesn't work on Lollipop version. In lollipop when I kick start my application it looks like it is opening the device admin activity, but immediately the activity animation stops and it closes without prompting the user to enable device admin. However, my application shows up in the settings->security->device administrator window, but it is unchecked as a device admin.</p>