Tutorials

    How WhatsApp Shows Incoming Calls on the Android Lock Screen

    A
    AzeemNov 23, 2026 ยท 10 min read
    45
    How WhatsApp Shows Incoming Calls on the Android Lock Screen

    Understanding FCM, Full-Screen Intents, CallStyle Notifications, and Foreground Services.

    You're watching a YouTube video, or perhaps your phone is locked in your pocket. Suddenly, someone calls you on WhatsApp.

    Your screen wakes up, and a full-screen incoming call interface appears with Answer and Decline buttons.

    Now imagine you're building a similar calling feature in your Android application.

    Your backend sends an incoming call event, and you try the obvious approach:

    val intent = Intent(
        context,
        IncomingCallActivity::class.java
    )
    context.startActivity(intent)
    code

    Android blocks it.

    Since Android 10 (API 29), applications cannot freely launch Activities from the background. This restriction prevents applications from unexpectedly taking over the screen while users are interacting with other applications.

    So how do applications like WhatsApp display incoming calls even when their Activity isn't running?

    The answer isn't a single API. It's a combination of Android components working together.

    Let's understand the complete implementation.

    1. Understanding the incoming call flow

    There are five important components involved:

    1. High-priority FCM: Delivers the incoming call event.

    2. Full-Screen Intent: Allows Android to launch the call Activity when appropriate.

    3. CallStyle Notification: Provides dedicated Answer and Decline actions.

    4. Lock Screen Activity: Allows the call UI to appear over the lock screen.

    5. Foreground Service: Supports the ongoing call after the user answers.

    Here's how they work together:

    Backend
       |
       v
    High-Priority FCM
       |
       v
    FirebaseMessagingService
       |
       v
    Create Incoming Call Notification
       |
       +------ Full-Screen Intent
       |
       +------ CallStyle Notification
       |
       v
    Android System
       |
       +------ Phone Locked
       |          |
       |          v
       |     Full-Screen Activity
       |
       +------ Phone Unlocked
                  |
                  v
            Heads-Up Notification
                  |
                  v
              User Answers
                  |
                  v
           Foreground Service
              (phoneCall)
    code

    The important thing to understand is that your application doesn't directly launch the Activity. Android's notification system decides how the incoming call should be presented.

    2. Step 1: Delivering incoming calls using high-priority FCM

    Suppose User A calls User B.

    Your backend needs to notify User B's device, even if the application isn't currently open.

    For this, we use Firebase Cloud Messaging (FCM).

    The backend sends a high-priority data message containing the call information:

    {
      "type": "INCOMING_CALL",
      "callId": "call_123",
      "callerId": "user_456",
      "callerName": "Rahul",
      "callType": "VIDEO"
    }
    code

    Firebase invokes your FirebaseMessagingService when the message is delivered.

    class MyFirebaseMessagingService :
        FirebaseMessagingService() {
    
        override fun onMessageReceived(
            message: RemoteMessage
        ) {
            val data = message.data
    
            if (data["type"] == "INCOMING_CALL") {
                handleIncomingCall(data)
            }
        }
    }
    code

    High-priority FCM is useful because it allows time-sensitive, user-visible events to be delivered with higher priority than ordinary background messages.

    It can give your application an opportunity to process the event even when its process isn't currently running.

    However, remember three things:

    • High priority doesn't guarantee instant delivery. Network conditions, Doze mode, and device-specific restrictions can affect delivery.

    • Force-stopped applications cannot rely on receiving FCM messages until the user opens them again.

    • FCM may deprioritize high-priority messages if they repeatedly don't result in user-visible notifications.

    Important: FCM only delivers the incoming call event. It doesn't automatically open your Activity.

    For that, we need Full-Screen Intents.

    3. Step 2: Full-Screen Intent - The key to displaying incoming calls

    Android provides an API called setFullScreenIntent().

    It allows you to associate a notification with an Activity that Android can launch when a full-screen presentation is appropriate.

    Instead of calling startActivity(), we create a PendingIntent.

    val fullScreenPendingIntent =
        PendingIntent.getActivity(
            context,
            100,
            Intent(
                context,
                IncomingCallActivity::class.java
            ),
            PendingIntent.FLAG_UPDATE_CURRENT or
                PendingIntent.FLAG_IMMUTABLE
        )
    code

    Now attach it to the notification:

    val notification =
        NotificationCompat.Builder(
            context,
            CALL_CHANNEL_ID
        )
            .setSmallIcon(R.drawable.ic_call)
            .setContentTitle("Incoming call")
            .setContentText("Rahul is calling...")
            .setCategory(NotificationCompat.CATEGORY_CALL)
            .setPriority(NotificationCompat.PRIORITY_MAX)
            .setFullScreenIntent(
                fullScreenPendingIntent,
                true
            )
            .setOngoing(true)
            .build()
    
    NotificationManagerCompat
        .from(context)
        .notify(CALL_NOTIFICATION_ID, notification)
    code

    Now Android decides how to display the incoming call.

    Scenario 1: Phone is locked

    Android can launch your full-screen Activity over the lock screen.

    Scenario 2: Phone is unlocked

    Imagine the user is watching YouTube or browsing Instagram.

    Android generally avoids interrupting the current application with a full-screen Activity. Instead, it displays a heads-up notification.

    This means your application must support both experiences:

    • Full-screen incoming call UI.

    • Incoming call notification with Answer and Decline actions.

    The decision belongs to Android's notification system, not your application.

    Don't forget notification channels.

    Since Android 8.0 (API 26), notification importance is controlled through channels.

    For incoming calls, create a channel with high importance:

    val channel = NotificationChannel(
        CALL_CHANNEL_ID,
        "Incoming Calls",
        NotificationManager.IMPORTANCE_HIGH
    )
    
    notificationManager.createNotificationChannel(channel)
    code

    The user can subsequently change the channel's importance in Settings.

    4. Step 3: CallStyle Notifications (Android 12+)

    Have you noticed that incoming call notifications look different from regular notifications?

    They display caller information and dedicated Answer and Decline actions.

    Android provides a dedicated notification template for this purpose: Notification.CallStyle.

    It was introduced in Android 12 (API 31) and is also available through AndroidX using NotificationCompat.CallStyle.

    First, create a Person representing the caller:

    val caller = Person.Builder()
        .setName("Rahul")
        .setImportant(true)
        .build()
    code

    Now create the notification:

    val notification =
        NotificationCompat.Builder(
            context,
            CALL_CHANNEL_ID
        )
            .setSmallIcon(R.drawable.ic_call)
            .setCategory(NotificationCompat.CATEGORY_CALL)
            .setStyle(
                NotificationCompat.CallStyle.forIncomingCall(
                    caller,
                    declinePendingIntent,
                    answerPendingIntent
                )
            )
            .setFullScreenIntent(
                fullScreenPendingIntent,
                true
            )
            .setOngoing(true)
            .build()
    code

    Notice that we use three different PendingIntents:

    Full-Screen: Opens the incoming call screen.
    Answer: Accepts the call.
    Decline: Rejects the call.

    CallStyle gives calling notifications dedicated system presentation and ranking treatment.

    One implementation detail worth remembering: a CallStyle notification should be associated with either a full-screen intent or a foreground service to receive its intended call-specific presentation.

    5. Step 4: Displaying the Activity over the lock screen

    When Android launches your incoming call Activity, we still need to configure it for lock-screen presentation.

    Android provides two important APIs: setShowWhenLocked(true)

    Allows your Activity to appear over the lock screen. setTurnScreenOn(true)

    Allows your Activity to turn on the display when launched.

    These are separate behaviours. Here's a simple implementation:

    class IncomingCallActivity : ComponentActivity() {
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            setShowWhenLocked(true)
            setTurnScreenOn(true)
    
            setContent {
                IncomingCallScreen()
            }
        }
    }
    code

    You can also configure these properties through the Activity manifest attributes.

    Now your Activity can display the incoming call interface over the lock screen.

    There's another scenario you must handle: what if the caller cancels the call before the recipient answers?

    Your application should cancel the notification and finish the incoming call Activity. You should also implement a call timeout so users don't see outdated incoming call screens.

    6. Step 5: Keeping the call alive using a Foreground Service

    The user answers the call and presses the Home button to open another application. The calling Activity is no longer visible, but the conversation must continue. This is where a Foreground Service becomes important.

    For phone calls, Android provides a specific foreground service type: phoneCall

    For applications targeting Android 14 (API 34) and above, foreground service types and their corresponding permissions must be declared.

    For example: AndroidManifest.xml

    <uses-permission
        android:name="android.permission.FOREGROUND_SERVICE" />
    
    <uses-permission
        android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
    
    <uses-permission
        android:name="android.permission.MANAGE_OWN_CALLS" />
    
    <application>
    
        <service
            android:name=".CallForegroundService"
            android:exported="false"
            android:foregroundServiceType="phoneCall" />
    
    </application>
    code

    The phoneCall type has an important eligibility requirement.

    Your application must either hold MANAGE_OWN_CALLS and satisfy the requirements for a self-managed calling application, or hold the system's default dialer role.

    It isn't a generic foreground service type that every application can use simply because it supports VoIP. You can promote the service using:

    ServiceCompat.startForeground(
        this,
        NOTIFICATION_ID,
        notification,
        ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL
    )
    code

    Remember: a foreground service doesn't keep your Activity alive. They have separate lifecycles.

    The service supports the ongoing call, while your application remains responsible for audio handling, connection management, and call lifecycle.

    7. Android 14: Full-Screen Intent permission changes

    Android 14 introduced stricter rules for full-screen intent access.

    For applications targeting API 34 and above, Google Play's default grant is restricted to applications whose core functionality is calling or alarms.

    The relevant permission is:

    <uses-permission
        android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    code

    However, declaring this permission doesn't guarantee access.

    You should check availability at runtime:

    val notificationManager =
        getSystemService(NotificationManager::class.java)
    
    val canUseFullScreenIntent =
        notificationManager.canUseFullScreenIntent()
    code

    If access isn't available, an eligible application can guide the user to Settings:

    if (!notificationManager.canUseFullScreenIntent()) {
    
        val intent = Intent(
            Settings.ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT,
            Uri.parse("package:$packageName")
        )
    
        startActivity(intent)
    }
    code

    Without full-screen intent access, your application cannot rely on launching the full-screen call interface, and the notification may appear as a heads-up notification instead.

    8. Debugging: Why are incoming call notifications delayed?

    Imagine your application works perfectly on your device, but some users report that incoming call notifications arrive 15โ€“20 seconds late.

    Where would you start?

    I'd investigate these areas:

    1. FCM delivery: Verify that the backend sends a high-priority data message.

    2. Doze mode: Check whether background execution restrictions are affecting delivery.

    3. FCM deprioritization: Check whether previous high-priority messages resulted in visible notifications.

    4. OEM battery restrictions: Some manufacturers introduce additional background execution restrictions.

    5. Message handling: Avoid performing unnecessary network or database operations before posting the notification.

    6. Notification configuration: Verify notification permission, channel importance, full-screen intent access, and successful notification posting.

    Log timestamps at every stage:

    Backend sends FCM
           |
           v
    FCM receives message
           |
           v
    onMessageReceived()
           |
           v
    Notification posted
           |
           v
    Notification displayed
    code

    This helps identify exactly where the delay occurs instead of randomly changing battery optimization settings.

    Interview Questions Based on This Scenario

    In a senior Android interview, understanding API definitions isn't enough. Interviewers often explore how different components interact.

    Here are eight follow-up questions I'd ask:

    1. Why can't you simply call startActivity() from FirebaseMessagingService?

    2. What happens when an incoming call arrives while the user is watching YouTube?

    3. What's the difference between a regular notification and a CallStyle notification?

    4. Why do we need both setShowWhenLocked() and setTurnScreenOn()?

    5. What happens if USE_FULL_SCREEN_INTENT isn't granted on Android 14?

    6. What breaks if you forget to declare the phoneCall foreground service type?

    7. Does high-priority FCM guarantee immediate delivery?

    8. How would you handle an incoming VoIP call when a cellular call is already active?

    These questions test whether you understand the complete system behaviour, not just individual Android APIs.

    A full-screen incoming call isn't achieved through a single Android API.

    It's a combination of components working together:

    • FCM delivers the incoming call event.

    • Full-Screen Intent allows Android to launch the call Activity when appropriate.

    • CallStyle provides a dedicated calling notification experience.

    • showWhenLocked() and turnScreenOn() configure the Activity for lock-screen presentation.

    • Foreground Service supports the ongoing call after the user answers.

    The most important concept is that Android remains in control of when and how your Activity is presented.

    Knowing an API is one thing. Understanding why it exists, how it interacts with other components, and what happens when something goes wrong is what makes you a stronger Android engineer.

    Preparing for Your Next Android Career Move?

    After mentoring 600+ Android developers and conducting 200+ mock interviews, I've noticed a recurring pattern.

    Many experienced developers understand Kotlin, Jetpack Compose, Coroutines, and the Android framework. But when interviewers introduce real-world scenarios and start asking follow-up questions, things become challenging.

    That's exactly what I focus on in my Android Job Ready Bootcamp.

    It's designed for Android developers with 3โ€“12 years of experience who want to switch jobs and prepare for opportunities at top product companies.

    Over the next few months, we'll work on Android internals, real-world scenarios, Kotlin, Coroutines, Compose, Mobile System Design, machine coding, and mock interviews.

    The objective isn't just to cover more topics. It's to develop the technical depth and confidence required to handle challenging senior Android interviews.

    ๐Ÿ‘‰ Explore the Android Job Ready Bootcamp

    Was this helpful?

    Comments (0)

    No comments yet. Be the first to share your thoughts!

    Leave a Comment

    Get the latest updates

    Join our newsletter and never miss an article.

    By subscribing, you agree to our Privacy Policy and consent to receive updates.