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

What is the onTr...

Câu trả lời

The onTrimMemory method is a callback in Android that notifies your app when the system is running low on memory and your app should release resources to improve system performance[1][3]. It is part of the ComponentCallbacks2 interface, which extends the ComponentCallbacks interface with additional callbacks for finer-grained memory management[3].

The onTrimMemory method is called with a level parameter that indicates the memory situation and how much memory your app should try to free[1][2][3]. The levels range from TRIM_MEMORY_RUNNING_MODERATE when the device is beginning to run low on memory, to TRIM_MEMORY_COMPLETE when your app's process is nearing the end of the background LRU list and will likely be killed soon if more memory isn't freed[3].

When onTrimMemory is called, your app should release any non-critical resources it can to free up memory[1][3]. This may include:

  • Clearing bitmap caches
  • Unregistering listeners that are no longer needed...
expert

expert

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

senior

What are best practices for storing and protecting private API keys in applications?

middle

What is the difference between compileSdkVersion and targetSdkVersion ?

middle

What is Handler and what is it used for?

Bình luận

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

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