How does android Notification panel actually work? The truth behind notification pannel.

What you're seeing in below image, it is Android's adaptive notification layout. The same PhonePe notification is being displayed in two different states.

In the first image

The PhonePe notification is collapsed (compact view).

  • Android shows only a small preview.
  • The image banner is cropped into a thin strip.
  • The app name and detailed content are hidden to save space.
  • This happens when there are many notifications in the panel.

In the second image

The PhonePe notification is expanded.

  • The full image is shown.
  • The app name (PhonePe) and time (12:26 PM) are visible.
  • The notification has been given more vertical space.
  • This can happen if:
    • you tap the down-arrow (∨) to expand it,
    • Android automatically expands it because there are fewer notifications,
    • or the app marks it as a "big picture" style notification.

The technology behind this is called Notification Styles in Android.

PhonePe likely sends this as a BigPictureStyle notification:

  • Collapsed state: small banner preview.
  • Expanded state: full promotional image.

So the notification itself isn't changing; Android changes the layout dynamically depending on the available space and user interaction.

In simple terms:

One notification → multiple layouts.
Android decides whether to show the compact version or the expanded version.

This is similar to how WhatsApp notifications can show just:

"3 new messages"

or, when expanded, show the actual message previews.

The notification itself is not just a single static image pasted onto the screen.

What PhonePe sends to Android is usually something like:

  • Title: "Save 5% on all online spends"
  • Large image: the purple credit card advertisement
  • Actions: "Apply Now" (if provided)
  • Layout instructions: "Show this as a Big Picture notification"

Then Android's System UI generates the actual layout depending on the situation.

Think of it like this:

Website data → Browser creates the webpage
Notification data → Android creates the notification layout

So:

  • The purple promotional banner itself is a static image.
  • But the overall notification card (app name, timestamp, arrow, expanded/collapsed appearance, image size, spacing) is dynamically rendered by Android.

That's why:

  • In the collapsed state, the image becomes a small strip.
  • In the expanded state, the same image appears much larger.
  • The arrow icon changes direction (∨ or ∧).
  • On different Android versions or brands (Samsung, Xiaomi, OnePlus), the same PhonePe notification can even look slightly different.

If it were truly a single static screenshot-like image, Android wouldn't be able to:

  • expand it,
  • collapse it,
  • show the app name separately,
  • add action buttons,
  • group it with other notifications.

So the answer is:

The advertisement image is static, but the notification layout is dynamic and generated by Android at runtime.

This is one of the reasons why Android notifications feel "alive" rather than being simple pictures on the screen.

So the "layout change" you're observing is actually a feature of the Android notification system designed to keep the notification shade organized while still allowing rich content when needed.

How does it work?

Both the content and the layout instructions are sent as code, not as a ready-made picture of the entire notification.

A simplified version of what PhonePe's app might send to Android looks like this:

Notification.Builder builder = new Notification.Builder(context)
    .setSmallIcon(R.drawable.phonepe_icon)
    .setContentTitle("Save 5%")
    .setContentText("On all online spends")
    .setStyle(new Notification.BigPictureStyle()
        .bigPicture(advertisement_image))
    .setPriority(Notification.PRIORITY_DEFAULT);

Android receives this information:

Sent by PhonePe (code/data) What Android does
App icon Displays the PhonePe icon
Title text Shows "Save 5%"
Message text Shows the offer description
Image file Displays the purple advertisement
BigPictureStyle instruction Enables expandable image layout
Action buttons Creates "Apply Now" buttons
Priority level Decides how prominently to show it

Then the Android System UI takes this data and constructs the notification on the fly.

It's similar to HTML on a website:

<h1>Save 5%</h1>
<img src="card.jpg">
<button>Apply Now</button>

The browser decides how to display it on different screen sizes.

Likewise, Android decides:

  • How large the image should be,
  • Whether the notification is collapsed or expanded,
  • How much text to show,
  • How it should look on Samsung, Xiaomi, Pixel, etc.

So the flow is:

PhonePe App
     ↓
Notification code + content
     ↓
Android Notification Manager
     ↓
System UI renders the final layout
     ↓
You see the notification

This is why Android notifications are so flexible. The app developer doesn't design every pixel of the final notification; they provide data and styling instructions, and the operating system renders the actual appearance.

The instructions originate from code written by the app developer.

Here's the more precise picture:

If PhonePe is an Android app

The notification code is usually written in:

  • Kotlin (Google's preferred language today)
  • Java (very common, especially in older apps)

For example:

Kotlin

val notification = NotificationCompat.Builder(this, CHANNEL_ID)
    .setContentTitle("Save 5%")
    .setContentText("On all online spends")
    .setStyle(NotificationCompat.BigPictureStyle())
    .build()

Java

NotificationCompat.Builder builder =
    new NotificationCompat.Builder(this, CHANNEL_ID);

Both of these languages eventually get compiled into Android bytecode (DEX files).

Then, when the app runs:

Kotlin/Java code
        ↓
Android Framework APIs
        ↓
Notification Manager Service
        ↓
System UI process
        ↓
Notification displayed on screen

However, if the notification comes from Firebase Cloud Messaging (FCM), which many apps use for promotional notifications, the server may simply send a JSON payload like this:

{
  "title": "Save 5%",
  "body": "On all online spends",
  "image": "https://example.com/card.jpg"
}

The PhonePe app (through Android's notification APIs) then converts that data into the actual notification.

So the complete answer is:

  • The notification you see is not sent as a screenshot.
  • The app uses Android notification APIs, usually through Kotlin or Java code.
  • Sometimes the content itself arrives from the internet as JSON data.
  • Android's operating system finally renders the visual layout.

So when you received that PhonePe offer, what reached your phone was probably:

Data (title + image URL + instructions) → PhonePe app code (Java/Kotlin) → Android notification system → Final notification layout.

This separation is why the same notification can automatically adapt to different phones, screen sizes, and expanded/collapsed states.

In a way, a notification is like a mini web page generated by the operating system from code and resources sent by the app.

Steps of notification creation

Case 1: Promotional notifications (like PhonePe example)

PhonePe engineers
        ↓
Write notification-handling code into the PhonePe app
        ↓
PhonePe marketing/server team creates the offer data
        ↓
PhonePe servers send the notification data to your phone
        ↓
PhonePe app receives the data
        ↓
PhonePe app asks Android:
"Please show this notification using BigPicture style."
        ↓
Android System UI decides the final appearance
        ↓
You see the notification

So, Android doesn't decide what the notification is about, but it does decide how to render it within the rules provided by the app.

For example, PhonePe might say:

"Here is the title, image, and style. Please display it."

Then Android decides:

  • Expanded or collapsed?
  • How much image to show?
  • How much text to show?
  • Where to place the timestamp?
  • How it should look on Samsung vs Xiaomi vs Pixel?

An analogy

Think of PhonePe as a restaurant chef and Android as the waiter.

  • Chef (PhonePe): prepares the dish (notification content).
  • Waiter (Android): decides which plate to use, how to present it, and how to serve it according to restaurant rules.

The waiter cannot change the dish into something else, but can change the presentation.

So 

The notification code is already inside the PhonePe app installed on your phone. PhonePe's servers usually send data (message, image URL, offer details), not new code each time.

So a more accurate version is:

PhonePe engineers → write app code
        ↓
You install/update PhonePe
        ↓
PhonePe servers send notification data
        ↓
The PhonePe app on your phone processes that data
        ↓
Android renders the notification

This design is actually an important security feature: servers send data, but they generally cannot send arbitrary new code to be executed on your phone. Android allows the already-installed app to decide how to use that data.

Most users see notifications as just "messages that pop up." But from an engineering perspective, notifications are extremely important because they are often the main communication channel between an app and its users.

For example:

  • Banking apps → transaction alerts, fraud warnings.
  • PhonePe/Google Pay → payment success, cashback offers, reminders.
  • WhatsApp → incoming messages.
  • Google Maps → navigation directions.
  • Medicine apps → medication reminders.
  • Airlines → gate changes and boarding announcements.
  • Government apps → emergency alerts.

Because notifications are so important, Android has entire systems dedicated to them:

  • Notification channels (you can control categories of notifications)
  • Priority levels (urgent vs silent)
  • Expandable layouts
  • Action buttons ("Reply", "Pay", "Archive")
  • Lock screen privacy controls
  • Notification history
  • Do Not Disturb integration

In fact, many large companies have teams whose job is to improve notifications because a poorly designed notification can:

  • annoy users,
  • get ignored,
  • cause users to disable notifications,
  • or even lead to financial mistakes in banking apps.

What's fascinating is that something as ordinary as the notification shade combines many areas of computer science:

  • UI/UX design → making it readable and useful,
  • Operating systems → Android managing priorities and rendering,
  • Networking → servers delivering the data,
  • Security → ensuring apps can't misuse the system,
  • Software engineering → writing the code that ties everything together.

So your earlier thought—

"The notification panel is designed casually."

—is actually what most people assume. But once you look under the hood, you realize that a seemingly simple notification is the result of careful engineering decisions accumulated over many years.

This is true for many technologies around us. A light switch, a zipper, a loom, an AC unit, or a smartphone notification panel may look simple in everyday use, but each one contains a surprising amount of human thought, experimentation, and engineering. That curiosity—asking "How does this actually work?"—is often the beginning of understanding technology at a much deeper level.

Besides this, Android also perform several security checks, but it doesn't fully decide whether a notification is genuine or spam in the way an email spam filter does.

Think of Android as a security guard, not an editor.

What Android checks

Before showing a notification, Android verifies things like:

✅ Is the app allowed to post notifications?

  • Since Android 13, apps must ask for notification permission.

✅ Is the notification coming from an installed app?

  • A random website cannot directly inject notifications into your notification panel.

✅ Is the app properly signed?

  • Android verifies the app's digital signature.

✅ Does the notification follow Android's rules?

  • Valid notification channel?
  • Proper icon?
  • Correct format?

✅ Is it potentially dangerous?

  • Android may warn about suspicious behavior.
  • Google Play Protect scans apps for malware.

What Android usually does NOT know

Suppose PhonePe sends:

"Get 5% cashback"

Android cannot easily determine:

  • Is the offer good or bad?
  • Is it marketing or genuinely useful?
  • Is it annoying spam?
  • Is the cashback worth it?

Android sees:

App: PhonePe
Permission: Granted
Notification format: Valid
App signature: Valid

and says:

"This is a legitimate notification from the PhonePe app. I'll display it."


Then who decides spam?

There are several layers:

  1. Google Play review

    • Tries to prevent malicious apps.
  2. PhonePe's own policies

    • Their servers decide what notifications to send.
  3. User controls

    • You can disable notifications.
    • You can mute specific categories.
  4. Android notification channels

    • Apps can separate:
      • Payments
      • Promotions
      • Security alerts

You can disable promotions while keeping payment alerts.


An interesting distinction

Android is good at answering:

"Did PhonePe send this notification?"

But it is much less capable of answering:

"Should PhonePe have sent this notification?"

The first is a security question. The second is a business/content question.

So the chain is roughly:

PhonePe notification
        ↓
Android checks:
✓ Permission
✓ App identity
✓ Security rules
✓ Format
        ↓
Notification shown
        ↓
User decides:
Useful? Spam? Ignore? Disable?

This separation is intentional. If Android started deciding which advertisements, opinions, or offers are "good" or "bad," the operating system would become the judge of all app content. Instead, Android mainly verifies authenticity and safety, while leaving relevance and usefulness to the user.

Post a Comment

Previous Post Next Post

Ad01

Ad02