đĨ Normal Service vs Foreground Service – āĻŦ্āϰেāĻāύ-āĻĢ্āϰেāύ্āĻĄāϞি āϤুāϞāύা!
đĨ Normal Service vs Foreground Service – āĻŦ্āϰেāĻāύ-āĻĢ্āϰেāύ্āĻĄāϞি āϤুāϞāύা! đ
āĻāĻĒāύাāϰ āĻĢোāύেāϰ āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄে āĻ
āύেāĻ āĻাāĻ āĻāϞে, āĻিāύ্āϤু āϏāĻŦ āϏাāϰ্āĻিāϏ āĻāĻāϰāĻāĻŽ āύা!
đ Normal Service āĻāĻāĻĻāĻŽ āĻুāĻĒāĻাāĻĒ āĻাāĻ āĻāϰে, āĻāĻāĻাāϰ āĻেāϰāĻ āĻĒাā§ āύা!
đ Foreground Service Active āĻাāĻŦে āĻাāĻ āĻāϰে, āĻāĻāĻাāϰāĻে āύোāĻিāĻĢিāĻেāĻļāύ āĻĻেāĻাā§!
đĄ Normal Service vs Foreground Service – āĻĒাāϰ্āĻĨāĻ্āϝ!
| ⚡ āĻŦৈāĻļিāώ্āĻ্āϝ | đ¤ Normal Service | đĨ Foreground Service |
|---|---|---|
| āĻাāĻেāϰ āϧāϰāύ | āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄে āĻাāĻ āĻāϰে | āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄে āĻাāĻ āĻāϰāϞেāĻ āĻāĻāĻাāϰāĻে āĻাāύাā§ |
| User Interaction | āύা, āĻāĻāĻাāϰ āĻিāĻুāĻ āĻেāϰ āĻĒাā§ āύা | āĻš্āϝাঁ, āύোāĻিāĻĢিāĻেāĻļāύ āĻĻেāĻাā§ |
| āύোāĻিāĻĢিāĻেāĻļāύ | āύেāĻ | āĻŦাāϧ্āϝāϤাāĻŽূāϞāĻ |
| Android Kill āĻāϰāϤে āĻĒাāϰে? | āĻš্āϝাঁ, āϏāĻšāĻেāĻ | āύা, āϏāĻšāĻে āĻিāϞ āĻāϰা āϝাā§ āύা |
| Usage Example | Data Sync, Alarm, API Calls | Music Player, Google Maps, WhatsApp Call |
| Battery Optimization | āĻš্āϝাঁ, āĻŦ্āϝাāĻাāϰি āϏেāĻ āĻšā§ | āϤুāϞāύাāĻŽূāϞāĻ āĻāĻŽ āĻŦ্āϝাāĻাāϰি āϏেāĻ āĻšā§ |
| Priority Level | Low | High |
đĨ āϏāĻšāĻ āĻāĻĻাāĻšāϰāĻŖ – Normal vs Foreground Service!
đ´ Normal Service (āĻুāĻĒāĻাāĻĒ āĻাāĻ āĻāϰে)
- āϧāϰুāύ, āĻāĻĒāύাāϰ āĻ ্āϝাāĻĒ āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄে āĻĄাāĻা āϏিāĻ্āĻ āĻāϰāĻে!
- āĻāĻāĻাāϰ āĻোāύোāĻাāĻŦেāĻ āĻাāύāϤে āĻĒাāϰāĻŦে āύা!
- āĻ ্āϝাāύ্āĻĄ্āϰā§েāĻĄ āϝāĻāύ āĻুāĻļি āĻāĻাāĻে Kill āĻāϰāϤে āĻĒাāϰে!
đ Normal Service Example:
class MyNormalService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
// āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄে āĻাāĻ āĻļুāϰু!
return START_STICKY
}
override fun onBind(intent: Intent?): IBinder? {
return null
}
}
đĨ Foreground Service (āϏāϰাāϏāϰি āĻāĻāĻাāϰāĻে āĻাāύাā§!)
- āϧāϰুāύ, Spotify āĻŦা Google Maps āĻŦ্āϝāĻŦāĻšাāϰ āĻāϰāĻেāύ!
- āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄেāĻ āĻāϞāĻŦে, āĻিāύ্āϤু āύোāĻিāĻĢিāĻেāĻļāύ āĻĻেāĻাāĻŦে!
- āĻ ্āϝাāύ্āĻĄ্āϰā§েāĻĄ āϏāĻšāĻে āĻŦāύ্āϧ āĻāϰāϤে āĻĒাāϰāĻŦে āύা!
đ Foreground Service Example:
class MyForegroundService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val notification = createNotification()
startForeground(1, notification) // Foreground Service āĻাāϞু!
return START_STICKY
}
private fun createNotification(): Notification {
return NotificationCompat.Builder(this, "channelId")
.setContentTitle("Foreground Service Running")
.setContentText("This service is active!")
.setSmallIcon(R.drawable.ic_notification)
.build()
}
override fun onBind(intent: Intent?): IBinder? {
return null
}
}
đ āĻāĻŦে āĻোāύāĻা āĻŦ্āϝāĻŦāĻšাāϰ āĻāϰāĻŦেāύ?
✔ Normal Service: āϝāĻĻি āĻŦ্āϝাāĻāĻ্āϰাāĻāύ্āĻĄে āĻুāĻĒāĻাāĻĒ āĻাāĻ āĻāϰāϤে āĻšā§ (āϝেāĻŽāύ, API Call, Data Sync)।
✔ Foreground Service: āϝāĻĻি āĻāĻāĻাāϰāĻে āĻাāύিā§ে āĻাāĻ āĻāϰāϤে āĻšā§ (āϝেāĻŽāύ, Music Player, Location Tracking)।
đ¯ āϏংāĻ্āώেāĻĒে!
- Normal Service = Background Worker (User āĻাāύে āύা, āϏāĻšāĻে Kill āĻšā§!)
- Foreground Service = High Priority Worker (User āύোāĻিāĻĢিāĻেāĻļāύ āĻĒাā§, āϏāĻšāĻে Kill āĻšā§ āύা!)
đ āĻাāĻেāϰ āϧāϰāύ āĻŦুāĻে āĻŦেāĻে āύিāύ āĻোāύ āϏাāϰ্āĻিāϏ āϞাāĻāĻŦে! đđĨ
Comments
Post a Comment