Friday, May 25, 2012

Android ~ Manually terminating an application or an activity

Best Practice recommended for Android development is to leave memory management to Android OS itself. What this means is when user moves out of our activity/application, we need not call the finish method to destroy it and release memory rather leave the application running without “finishing” it. When Android OS runs low in memory, it may decide to terminate the running activities.

Ok having said that and during development, assume we are interested to start the application fresh. In order to achieve this, we have four ways to do it and they are as follows:

1.       Restart the emulator    
This will take longer time but you can achieve your expectation

2.       Re-run the application 
This too will take longer time but comparatively less than that of restarting the emulator and you will achieve your expectation

3.       Stop Process from DDMS view 
This is quickest method and can be done only from the Eclipse studio
Eclipse Studio -> DDMS Perspective view -> Devices panel -> select process -> click stop button

4.       Force stop from Settings             
This is also the quickest and the safest method you can do directly from the Android device.
                Android Emulator -> Settings -> Applications -> Manage Applications -> Running Tab -> Select Application -> Force Stop

No comments: