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

@ -206,6 +206,22 @@
android:label="@string/customize_colors"
android:parentActivityName=".activities.SettingsActivity" />
<receiver
android:name=".receivers.BootCompletedReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.AutomaticBackupReceiver"
android:exported="false" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"

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()
}
}
}
}