Câu hỏi phỏng vấn Android
Câu hỏi

Explain activity lifecycle

Câu trả lời

Activity Lifecycle

The activity lifecycle in Android refers to the different states an activity can go through during its lifetime, from creation to destruction. Android manages the lifecycle of an activity using a series of callback methods that are called at specific points in the activity's lifecycle. Here's an explanation of the activity lifecycle and its callback methods:

1. onCreate()

This method is called when the activity is first created. It is used to perform one-time initialization tasks, such as setting up the user interface, initializing variables, and registering event listeners.

2. onStart()

This method is called when the activity becomes visible to the user. It is used to prepare the activity for user interaction.

3. onResume()

This method is called when the activity starts interacting with the user. It is used to start animations, open resources, and begin interactions that were paused in the onPause() method.

4. onPause()

This method is called when the activity is about to go into the background, either because another activity is being launched or because the activity itself is being destroyed. It is used to save data, stop animations, and release system resources that are not needed while the activit...

junior

junior

Gợi ý câu hỏi phỏng vấn

junior

Is it possible to implement the Model–View–Controller pattern in Java for Android?

middle

What are the permission protection levels in Android?

middle

How would you support different screen sizes?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào