Showing the single result
Price
Category
Promt Tags
BatteryAlert
Create Android notification text
€14.14 – €18.33Price range: €14.14 through €18.33Notification Message:
Title: Battery Critically Low
Message: Your battery level is below 10%. Please connect your device to a charger to avoid shutdown.
Additional Details:
- Notification Importance: High
- Actions: Include a single action button labeled “Open Battery Saver” that redirects users to the battery saver settings.
Example Implementation in Kotlin:
val notificationId = 101
val channelId = "battery_alert_channel"
val intent = Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS)
val pendingIntent = PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val notificationBuilder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_battery_alert)
.setContentTitle("Battery Critically Low")
.setContentText("Your battery level is below 10%. Please connect your device to a charger to avoid shutdown.")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_SYSTEM)
.setAutoCancel(true)
.addAction(
R.drawable.ic_battery_saver,
"Open Battery Saver",
pendingIntent
)
val notificationManager = NotificationManagerCompat.from(context)
notificationManager.notify(notificationId, notificationBuilder.build())
Considerations:
- Notification Channel: Ensure a channel (
battery_alert_channel) is registered with appropriate importance (IMPORTANCE_HIGH) for Android 8.0 (API 26) and above. - Action Button: Provide a meaningful action for users to address the issue promptly.
- Dismissal: The notification should be dismissible after user acknowledgment or resolution.