title: Trying to make my application device owner in simulator
body: <p><strong>What I am trying to do:</strong> I am trying to make app device owner</p>
  
  <p><strong>What I am using:</strong> I am using a simulator to try this </p>
  
  <hr>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.cnx.silentupdate"&gt;
  
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:testOnly="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;receiver
              android:name=".DevAdminReceiver"
              android:label="@string/app_name"
              android:permission="android.permission.BIND_DEVICE_ADMIN" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /&gt;
              &lt;/intent-filter&gt;
  
              &lt;meta-data
                  android:name="android.app.device_admin"
                  android:resource="@xml/device_admin" /&gt;
          &lt;/receiver&gt;
  
          &lt;receiver
              android:name=".UpdateReceiver"&gt;
  
              &lt;intent-filter &gt;
                  &lt;action  android:name="android.intent.action.MY_PACKAGE_REPLACED"/&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>DevAdminReceiver.kt</strong></p>
  
  <pre><code>class DevAdminReceiver : DeviceAdminReceiver() {
      override fun onEnabled(context: Context?, intent: Intent?) {
          super.onEnabled(context, intent)
          Log.d(TAG, "Device Owner Enabled")
          Toast.makeText(context,"Device Owner Enabled",Toast.LENGTH_LONG).show()
      }
  }
  </code></pre>
  
  <p><strong>UpdateReceiver.kt</strong></p>
  
  <pre><code>class UpdateReceiver : BroadcastReceiver() {
  
      override fun onReceive(context: Context, intent: Intent) {
  
          // Restart app here
          val i = Intent(context, MainActivity::class.java)
          i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
          context.startActivity(i)
          Toast.makeText(context,"Restart app here", Toast.LENGTH_LONG).show()
      }
  }
  </code></pre>
  
  <p><strong>device_admin.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;device-admin xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;uses-policies&gt;
      &lt;/uses-policies&gt;
  &lt;/device-admin&gt;
  </code></pre>
  
  <p><strong>MainActivity.kt</strong></p>
  
  <pre><code> @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
      override fun onResume() {
          super.onResume()
          val dpm = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
          if (dpm.isDeviceOwnerApp(packageName)){
              Log.d(TAG, "is device owner")
              Toast.makeText(this,"is device owner", Toast.LENGTH_LONG).show()
          }else{
              Log.d(TAG, "not device owner")
              Toast.makeText(this,"not device owner", Toast.LENGTH_LONG).show()
          }
  
          tv_text.text = "version code=" + BuildConfig.VERSION_CODE
      }
  </code></pre>
  
  <hr>
  
  <p><strong>When I am trying the command:</strong> I get the error as below </p>
  
  <pre><code>admins-MacBook-Pro:platform-tools devrath$ ./adb shell dpm set-device-owner eu.sisik.devowner/.DevAdminReceiver
      usage: dpm [subcommand] [options]
      usage: dpm set-active-admin [ --user &lt;USER_ID&gt; | current ] &lt;COMPONENT&gt;
      usage: dpm set-device-owner [ --user &lt;USER_ID&gt; | current *EXPERIMENTAL* ] [ --name &lt;NAME&gt; ] &lt;COMPONENT&gt;
      usage: dpm set-profile-owner [ --user &lt;USER_ID&gt; | current ] [ --name &lt;NAME&gt; ] &lt;COMPONENT&gt;
      usage: dpm remove-active-admin [ --user &lt;USER_ID&gt; | current ] [ --name &lt;NAME&gt; ] &lt;COMPONENT&gt;
  
      dpm set-active-admin: Sets the given component as active admin for an existing user.
  
      dpm set-device-owner: Sets the given component as active admin, and its package as device owner.
  
      dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.
  
      dpm remove-active-admin: Disables an active admin, the admin must have declared android:testOnly in the application in its manifest. This will also remove device and profile owners.
  
      dpm clear-freeze-period-record: clears framework-maintained record of past freeze periods that the device went through. For use during feature development to prevent triggering restriction on setting freeze periods.
  
      dpm force-security-logs: makes all security logs available to the DPC and triggers DeviceAdminReceiver.onSecurityLogsAvailable() if needed.
  
      Error: Unknown admin: ComponentInfo{eu.sisik.devowner/eu.sisik.devowner.DevAdminReceiver}
  </code></pre>