Skip to content

Commit

Permalink
chore: modify workManager
Browse files Browse the repository at this point in the history
  • Loading branch information
HI-JIN2 committed Sep 17, 2024
1 parent 9f30c2a commit fb39f03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
25 changes: 22 additions & 3 deletions app/src/main/java/com/eatssu/android/NotificationWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package com.eatssu.android

import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.eatssu.android.ui.main.MainActivity

class NotificationWorker(context: Context, params: WorkerParameters) : Worker(context, params) {

Expand All @@ -23,17 +26,33 @@ class NotificationWorker(context: Context, params: WorkerParameters) : Worker(co
val channel = NotificationChannel(
CHANNEL_ID,
"Daily Notification Channel",
NotificationManager.IMPORTANCE_DEFAULT
NotificationManager.IMPORTANCE_HIGH
)
notificationManager.createNotificationChannel(channel)
}

// 메인 μ•‘ν‹°λΉ„ν‹°λ‘œ μ΄λ™ν•˜λŠ” Intent 생성
val intent = Intent(applicationContext, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}

// PendingIntent 생성
val pendingIntent = PendingIntent.getActivity(
applicationContext,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)

val builder = NotificationCompat.Builder(applicationContext, CHANNEL_ID)
.setSmallIcon(R.drawable.img_logo2)
.setSmallIcon(R.drawable.img_new_logo)
.setContentTitle(applicationContext.getString(R.string.notification_context_title))
.setContentText(applicationContext.getString(R.string.notification_context_text))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setPriority(NotificationCompat.PRIORITY_HIGH) // 높은 μš°μ„ μˆœμœ„ μ„€μ •
.setCategory(NotificationCompat.CATEGORY_ALARM) // μ•ŒλžŒ μΉ΄ν…Œκ³ λ¦¬λ‘œ μ„€μ •
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) // 잠금 ν™”λ©΄μ—μ„œλ„ ν‘œμ‹œ
.setAutoCancel(true)
.setContentIntent(pendingIntent) // 클릭 μ‹œ μ‹€ν–‰ν•  PendingIntent μ„€μ •

notificationManager.notify(NOTIFICATION_ID, builder.build())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ class MyPageActivity : BaseActivity<ActivityMyPageBinding>(ActivityMyPageBinding
val currentTimeMillis = System.currentTimeMillis()
val calendar = Calendar.getInstance().apply {
timeInMillis = currentTimeMillis
set(Calendar.HOUR_OF_DAY, 17)
set(Calendar.MINUTE, 35)
set(Calendar.HOUR_OF_DAY, 18)
set(Calendar.MINUTE, 20)
set(Calendar.SECOND, 0)
set(Calendar.MILLISECOND, 0)
}
Expand Down
Binary file added app/src/main/res/drawable/img_new_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fb39f03

Please sign in to comment.