AnkiDroid Companion uses Android’s notification system to display flashcards directly in your notification tray. The notification system supports both collapsed and expanded views, with interactive buttons for submitting card reviews.
When all cards are completed, the notification shows a congratulations message:
if (card != null) { // Show card notification with buttons} else { collapsedView.setTextViewText(R.id.textViewCollapsedHeader, "Congrats! You've finished the deck!") collapsedView.setTextViewText(R.id.textViewCollapsedTitle, "Anki") val expandedView = RemoteViews(context.packageName, R.layout.notification_expanded_empty) expandedView.setTextViewText(R.id.textViewEmptyExpandedHeader, "Congrats! You've finished the deck!") expandedView.setTextViewText(R.id.textViewEmptyExpandedContent, "New notifications will arrive when it's time to study!") builder = NotificationCompat.Builder(context, "channel_id") // ... .setOngoing(false) // Can be dismissed}
From Notifications.kt:63-80
The empty state notification is not ongoing, allowing users to dismiss it.
Before showing a new notification, the app cancels the previous one to avoid duplicates:
val notification: Notification = builder.build()val notificationManager: NotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManagernotificationManager.cancel(1) // Cancel the current notificationnotificationManager.notify(1, notification) // Show new notification