# Lifecycle ของ Android (Android) > Lifecycle ของ Activity/Fragment, Configuration Changes และการจัดการ state - 30 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Android](https://sharpskill.dev/th/technologies/android/interview-questions.md) ## 1. ลำดับ lifecycle ที่ถูกต้องของ Activity เมื่อเริ่มต้นคืออะไร? **คำตอบ** Lifecycle ของ Activity เริ่มต้นด้วย onCreate() (การ initialize และสร้าง view) ตามด้วย onStart() (Activity แสดงผลแต่ยังโต้ตอบไม่ได้) แล้วตามด้วย onResume() (Activity อยู่ใน foreground และโต้ตอบได้) ลำดับนี้จะเหมือนเดิมเสมอในทุกครั้งที่ Activity เริ่มต้น ## 2. เมธอด lifecycle ตัวแรกตัวใดที่ถูกเรียกเมื่อ Activity ไปยัง background? **คำตอบ** onPause() เป็นเมธอดแรกที่ถูกเรียกเมื่อ Activity เริ่มสูญเสีย focus ตามด้วย onStop() เมื่อ Activity ไม่แสดงผลอีกต่อไป ข้อมูลสำคัญควรถูกบันทึกใน onPause() เนื่องจากระบบอาจ kill process หลังเมธอดนี้โดยไม่เรียก onStop() ## 3. ควร initialize View (findViewById, ViewBinding) ในเมธอดใด? **คำตอบ** onCreate() เป็นเมธอดที่เหมาะสมในการ initialize View เนื่องจากเป็นที่ที่ setContentView() ถูกเรียกและลำดับชั้นของ View ถูกสร้างขึ้น View ยังไม่พร้อมใช้งานก่อน onCreate() คุณสามารถใช้ onViewCreated() ใน Fragment ได้เช่นกัน ## มีอีก 27 คำถาม - ความแตกต่างระหว่าง onPause() และ onStop() คืออะไร? - เกิดอะไรขึ้นเมื่อหมุนหน้าจอโดยค่าเริ่มต้น? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Android อื่นๆ - [พื้นฐาน Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-fundamentals.md): 24 คำถาม, Junior - [UI และทรัพยากร Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-ui-and-resources.md): 30 คำถาม, Junior - [การนำทาง Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-navigation.md): 26 คำถาม, Junior - [การจัดการข้อมูล Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-data-management.md): 29 คำถาม, Junior - [Networking Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-networking.md): 29 คำถาม, Junior - [การทดสอบ Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-testing.md): 28 คำถาม, Junior - [Android Gradle](https://sharpskill.dev/th/technologies/android/interview-questions/android-gradle.md): 26 คำถาม, Junior - [พื้นฐานภาษา Kotlin สำหรับ Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-kotlin-language-essentials.md): 24 คำถาม, Junior - [Room Database](https://sharpskill.dev/th/technologies/android/interview-questions/android-room-database.md): 25 คำถาม, Mid-Level - [การทำงานเบื้องหลัง](https://sharpskill.dev/th/technologies/android/interview-questions/android-background-work.md): 18 คำถาม, Mid-Level - [Jetpack Compose](https://sharpskill.dev/th/technologies/android/interview-questions/android-compose.md): 28 คำถาม, Mid-Level - [สิทธิ์และฟีเจอร์ของอุปกรณ์](https://sharpskill.dev/th/technologies/android/interview-questions/android-permissions-and-device.md): 21 คำถาม, Mid-Level - [Firebase สำหรับ Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-firebase.md): 23 คำถาม, Mid-Level - [Android MVVM Architecture](https://sharpskill.dev/th/technologies/android/interview-questions/android-mvvm-architecture.md): 18 คำถาม, Mid-Level - [เครือข่าย Android ขั้นสูง](https://sharpskill.dev/th/technologies/android/interview-questions/android-networking-advanced.md): 13 คำถาม, Mid-Level - [Collections และ Operators ใน Kotlin](https://sharpskill.dev/th/technologies/android/interview-questions/android-kotlin-collections-operators.md): 20 คำถาม, Mid-Level - [Kotlin Coroutines และ Flow](https://sharpskill.dev/th/technologies/android/interview-questions/android-kotlin-coroutines-flow.md): 20 คำถาม, Mid-Level - [การฉีด Dependency ใน Android](https://sharpskill.dev/th/technologies/android/interview-questions/android-dependency-injection.md): 15 คำถาม, Mid-Level - [Android MVI Architecture](https://sharpskill.dev/th/technologies/android/interview-questions/android-mvi-architecture.md): 17 คำถาม, Mid-Level - [Android Clean Architecture](https://sharpskill.dev/th/technologies/android/interview-questions/android-clean-architecture.md): 21 คำถาม, Senior - [Android Compose ขั้นสูง](https://sharpskill.dev/th/technologies/android/interview-questions/android-compose-advanced.md): 17 คำถาม, Senior - [Android Performance and Monitoring](https://sharpskill.dev/th/technologies/android/interview-questions/android-performance-monitoring.md): 13 คำถาม, Senior - [Android Security and Privacy](https://sharpskill.dev/th/technologies/android/interview-questions/android-security-privacy.md): 18 คำถาม, Senior - [Android CI/CD and Release](https://sharpskill.dev/th/technologies/android/interview-questions/android-cicd-release.md): 15 คำถาม, Senior - [Android UX and Form Factors](https://sharpskill.dev/th/technologies/android/interview-questions/android-ux-form-factors.md): 18 คำถาม, Senior - [Android Testing Advanced](https://sharpskill.dev/th/technologies/android/interview-questions/android-testing-advanced.md): 18 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/android/interview-questions/android-lifecycle