Issue
I'm developing an Android app, and I already read about the lifecycle of an activity. I don't know, what's happens if I don't implement the methods of the lifecycle onCreate(), onDestroy(), etc.. The JVM calls automatically these methods? I'm habitual in iOS, and the change to Java is some peculiar for me. I want call the methods to manage memory. I'm supponing that these methods helps to manage the memory in my App and this not crash in runtime.
Solution
The Android framework always calls those methods. If you don't implement them, the base class methods will be run. Typically they do nothing (significant). However, you definitely need to override some of the methods (at least onCreate
) to make your activity useful.
As far as memory management goes, you usually should not worry about that at all. Java has automatic garbage collection that works very well. Unlike Objective C, in Java there is actually no mechanism for manual memory management; it's always done by the JVM. The only thing you need to pay attention to as far as memory management goes is to be sure you don't maintain hard references to large data structures that you no longer need. See the article Avoiding Memory Leaks in the Android blog.
Answered By - Ted Hopp
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.