intent.action == "android.app.action.PROFILE_PROVISIONING_COMPLETE" not firing
But onReceive is called
i tried to get in in a "PROFILE_PROVISIONING_COMPLETE" receiver but it din´t work
MyDeviceAdminReceiver.kt
// MyDeviceAdminReceiver.kt
package com.deviceadmin
import android.content.Context
import android.content.Intent
import android.widget.Toast
import android.app.admin.DeviceAdminReceiver
import android.os.Build
class MyDeviceAdminReceiver : DeviceAdminReceiver() {
override fun onEnabled(context: Context, intent: Intent) {
super.onEnabled(context, intent)
Toast.makeText(context, "Device Admin Enabled", Toast.LENGTH_SHORT).show()
}
override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, intent)
// Check if the action indicates provisioning is complete.
if (intent.action == "android.app.action.PROFILE_PROVISIONING_COMPLETE") {
Toast.makeText(context, "Provisioning Complete", Toast.LENGTH_SHORT).show()
// Start the LocationService.
val serviceIntent = Intent(context, LocationService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(serviceIntent)
} else {
context.startService(serviceIntent)
}
} else {
// Handle other actions if needed.
Toast.makeText(context, "Device Admin onReceive", Toast.LENGTH_SHORT).show()
}
}
override fun onDisabled(context: Context, intent: Intent) {
super.onDisabled(context, intent)
Toast.makeText(context, "Device Admin Disabled", Toast.LENGTH_SHORT).show()
}
}