When I run adb shell dpm-set-device-owner com.example.park_app/com.example.park_app.MyAdmin, it returns Error: Unknown admin: ComponentInfo{com.example.park_app/com.example.park_app.MyAdmin.java}
D:\workspace\Taichung Park\Park_App>adb shell dpm set-device-owner
com.example.park_app/com.example.park_app.MyAdmin.java
usage: dpm [subcommand] [options]
usage: dpm set-active-admin [ --user <USER_ID> | current ] <COMPONENT>
usage: dpm set-device-owner [ --user <USER_ID> | current *EXPERIMENTAL* ] [ --name <NAME> ] <COMPONENT>
usage: dpm set-profile-owner [ --user <USER_ID> | current ] [ --name <NAME> ] <COMPONENT>
usage: dpm remove-active-admin [ --user <USER_ID> | current ] [ --name <NAME> ] <COMPONENT>
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{com.example.park_app/com.example.park_app.MyAdmin.java}
AndroidManifest.xml:
<receiver android:name="com.example.park_app.MyAdmin"
android:label="ParkAppAdmin"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
MyAdmin.java:
public class MyAdmin extends DeviceAdminReceiver {
@Override
public void onProfileProvisioningComplete(@NonNull Context context, @NonNull Intent intent) {
DevicePolicyManager devicePolicyManager =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName componentName = getComponentName(context);
devicePolicyManager.setProfileName(componentName, "KioskMode");
Intent launch = new Intent(context, MainActivity.class);
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(launch);
}
@Override
public void onEnabled(@NonNull Context context, @NonNull Intent intent) {
System.out.println("onEnabled");
}
@Override
public void onDisabled(@NonNull Context context, @NonNull Intent intent) {
System.out.println("onDisabled");
}
private ComponentName getComponentName(Context context){
return new ComponentName(context.getApplicationContext(), MyAdmin.class);
}
}
How can I fix the issue to make application a device owner