Last active
April 22, 2024 06:30
-
-
Save SANDY-9/f31007bdd592da46d81de32feb39749c to your computer and use it in GitHub Desktop.
기기 재부팅 상태 이벤트 수신하는 브로드캐스트리시버
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.BroadcastReceiver | |
import android.content.Context | |
import android.content.Intent | |
import android.content.SharedPreferences | |
import com.sandy.seoul_matcheap.util.constants.APP_PREFS_SETTINGS | |
import com.sandy.seoul_matcheap.util.helper.AppPrefsUtils | |
import dagger.hilt.android.AndroidEntryPoint | |
import javax.inject.Inject | |
import javax.inject.Named | |
@AndroidEntryPoint | |
class SystemBootReceiver: BroadcastReceiver() { | |
@Inject | |
lateinit var notificationScheduler: NotificationScheduler | |
@Inject @Named(APP_PREFS_SETTINGS) | |
lateinit var prefs : SharedPreferences | |
override fun onReceive(context: Context?, intent: Intent?) { | |
// BOOT_COMPLETED상태 수신 | |
if (intent?.action == "android.intent.action.BOOT_COMPLETED") { | |
// 등록된 알람이 있는지 확인하고 재예약하는 로직 | |
val time = AppPrefsUtils.getSavedTime(prefs) | |
val register = AppPrefsUtils.getNotificationState(prefs) | |
notificationScheduler.setNotificationSchedule(register, time) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AndroidManifest.xml