Но Onceive называется < /p>
Я пытался войти В приемнике "profile_provisioning_complete", но он работает < /p>
mydeviceadminreceiver.ktобразной div class = "snippet-code">
Код: Выделить всё
// 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()
}
}< /code>
< /div>
< /div>
< /p>
функция Увольнение и меня опробовали метод ProfileProvision, не вызывая < /p>
androidmanifest.xml
Пожалуйста, помогите мне ...
Подробнее здесь: https://stackoverflow.com/questions/794 ... not-firing
Мобильная версия