v1.2.4: Deprecation 경고 수정 및 삭제 알람 버그 수정

This commit is contained in:
2026-02-23 12:48:37 +09:00
parent 161cc8060d
commit fdcbb615ab
5 changed files with 52 additions and 14 deletions

View File

@@ -15,6 +15,13 @@ class AlarmReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent?) {
Log.d(TAG, "===== 알람 수신 (Receiver) =====")
// 마스터 알람이 꺼져있으면 알람 무시
val prefs = context.getSharedPreferences("ShiftAlarmPrefs", Context.MODE_PRIVATE)
if (!ShiftAlarmDefaults.isMasterAlarmEnabled(prefs)) {
Log.w(TAG, "마스터 알람이 꺼져있어 알람을 무시합니다.")
return
}
val alarmId = intent?.getIntExtra("EXTRA_ALARM_ID", -1) ?: -1
val isCustom = intent?.getBooleanExtra("EXTRA_IS_CUSTOM", false) ?: false
@@ -50,6 +57,7 @@ class AlarmReceiver : BroadcastReceiver() {
private fun startAlarm(context: Context, intent: Intent?) {
// WakeLock 획득 (화면 켜기 및 Activity 실행 보장)
val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
@Suppress("DEPRECATION")
val wakeLock = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK or PowerManager.ACQUIRE_CAUSES_WAKEUP,
"ShiftAlarm::AlarmWakeLock"
@@ -71,6 +79,8 @@ class AlarmReceiver : BroadcastReceiver() {
context.startService(serviceIntent)
}
Log.d(TAG, "ForegroundService 시작 완료")
// 2. AlarmActivity 직접 실행 (알람 화면 표시)
val activityIntent = Intent(context, AlarmActivity::class.java).apply {
putExtra("EXTRA_SHIFT", intent?.getStringExtra("EXTRA_SHIFT") ?: "근무")
@@ -88,8 +98,15 @@ class AlarmReceiver : BroadcastReceiver() {
addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
}
context.startActivity(activityIntent)
Log.d(TAG, "AlarmActivity 실행 완료")
// 지연 후 Activity 시작 (ForegroundService가 알림을 먼저 표시하도록)
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
try {
context.startActivity(activityIntent)
Log.d(TAG, "AlarmActivity 실행 완료")
} catch (e: Exception) {
Log.e(TAG, "AlarmActivity 실행 실패", e)
}
}, 500)
} catch (e: Exception) {
Log.e(TAG, "알람 실행 실패", e)