[Android] When Exactly Is onPause() Called?

2025. 7. 22. 17:58·Android

Every time I study the Android activity lifecycle, the one callback that always feels vague and confusing is onPause().

While I understand the theory behind it, I often get confused about when exactly this method gets called during actual development.

 

What the Official Documentation Says

According to the Android official documentation:

The system calls this method as the first indication that the user is leaving the activity.

However, this does not necessarily mean the activity is being destroyed.

It simply indicates that the activity is no longer in the foreground.

 

The documentation outlines a few situations where onPause() is triggered:

  • An event interrupts the app’s execution (e.g., an incoming call)
  • In multi-window mode, when the focus shifts to another app
  • A semi-transparent screen appears and the current activity loses focus (e.g., a dialog)

 

Sounds Clear… But Is It Really?

When an incoming call occurs or another app takes focus in multi-window mode, it's clear that the current activity loses focus — and onPause() being called makes perfect sense.

But the third case, where a dialog partially covers the screen, was the most confusing one during actual development.

 

Even the official documentation states:

A new activity or dialog appears in the foreground, taking focus and partially covering the activity in progress.

→ The current activity enters the Paused state and onPause() is called.

 

Based on this, I assumed that any dialog appearing on the screen would trigger onPause().

But as I encountered more real-world scenarios, that assumption turned out to be inaccurate.

 

AlertDialog and DialogFragment Don’t Trigger onPause()?

I often use AlertDialog, DialogFragment, and BottomSheetDialogFragment in my projects.

To my surprise, when any of these dialogs were shown, onPause() was not called, even though it felt like the activity should have lost focus.

It was a moment of cognitive dissonance — everything I believed about onPause() was now in question.

 

The Only Dialog That Triggered onPause() — Permission Request Dialog

There was, however, one case where I did see onPause() being triggered: when the system’s permission request dialog appeared.

When this dialog was shown, the logs clearly indicated that onPause() was called — exactly as I expected.

But then, things got weirder.

 

A New Mystery

Here’s a snippet from my project:

private fun setupBindings() {
    binding.btnCheckIn.setOnClickListener {
        if (isLocationPermissionGranted()) {
            viewModel.checkIn()
        } else {
            requestLocationPermissions()
        }
    }
}

 

If the user had previously denied the permission multiple times, I manually showed an AlertDialog informing them that location permission is required.

Since it was a regular AlertDialog, I assumed onPause() would not be called.

But to my surprise, the logs showed this:

onPause()
onResume()

Wait… why is onPause() being called for a regular dialog?

 

I haven’t figured out the exact cause yet, but my guess is that the process of showing the AlertDialog might temporarily steal focus — possibly due to how the window or UI thread is handled behind the scenes.

I plan to investigate further and will update this post once I know more.

 

What GPT Had to Say

I asked GPT about this behavior, and the response was insightful:

  • For typical AlertDialog and DialogFragment instances, onPause() is usually not triggered.
  • However, if the dialog is actually a dialog-themed Activity, then onPause() will be called.

I haven't personally tested dialog-style activities yet, but I plan to explore that area next.

'Android' 카테고리의 다른 글

Retrofit에서 Ktor로: 안드로이드 HTTP 클라이언트 마이그레이션  (0) 2026.01.08
[Android] Safely Refreshing Tokens with Authenticator and Mutex  (0) 2025.09.10
[Android] Improving BottomNavigation Fragment Switching Performance  (0) 2025.08.13
'Android' 카테고리의 다른 글
  • Retrofit에서 Ktor로: 안드로이드 HTTP 클라이언트 마이그레이션
  • [Android] Safely Refreshing Tokens with Authenticator and Mutex
  • [Android] Improving BottomNavigation Fragment Switching Performance
jiyuneel
jiyuneel
  • jiyuneel
    Yuun
    jiyuneel
  • 전체
    오늘
    어제
    • 분류 전체보기 (6)
      • Android (4)
      • Kotlin (2)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    Android
    Android Studio
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
jiyuneel
[Android] When Exactly Is onPause() Called?
상단으로

티스토리툴바