Added receivers to manifest

This commit is contained in:
merkost
2023-07-15 13:45:11 +10:00
parent f2a098c9c4
commit cc332fb0a8
3 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package com.simplemobiletools.contacts.pro.receivers
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.PowerManager
import com.simplemobiletools.contacts.pro.extensions.backupContacts
class AutomaticBackupReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
val wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "simplecontacts:automaticbackupreceiver")
wakelock.acquire(3000)
context.backupContacts()
}
}

View File

@ -0,0 +1,18 @@
package com.simplemobiletools.contacts.pro.receivers
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.contacts.pro.extensions.checkAndBackupContactsOnBoot
class BootCompletedReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
ensureBackgroundThread {
context.apply {
checkAndBackupContactsOnBoot()
}
}
}
}