BatteryAlert

Create Android notification text

Price range: €14.14 through €18.33

Notification 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:

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:

  1. Notification Channel: Ensure a channel (battery_alert_channel) is registered with appropriate importance (IMPORTANCE_HIGH) for Android 8.0 (API 26) and above.
  2. Action Button: Provide a meaningful action for users to address the issue promptly.
  3. Dismissal: The notification should be dismissible after user acknowledgment or resolution.
Select options This product has multiple variants. The options may be chosen on the product page