In Android What Is Efficent Way For Use Of Activity
Solution 1:
Per the documentation for Activities, "An activity is a single, focused thing that the user can do". In other words, each different screen of your application should be an activity.
The only time you should have an Activity represent more than one screen is if it's a recursive action like a file browser; i.e. something that just changes the data that is displayed, but is displayed the same way.
Solution 2:
It's quite common to create one Activity for every logical "screen" of your application, but to share the same Activity for multiple "states" (eg. dialog boxes, different modes) of that screen.
The back button will automatically go backwards through Activities (by default) and you can override the back button within an activity to revert to a previous state within the same activity (ie. hiding a panel)
Solution 3:
Basically, Activity, in case of Android, is not a synonym for functionality. It is synonym for screen UI. Thus, how you implement your functionality is your choice. You just need to consider the following tips:
- If you use the same activity for categories and subcategories (using List elements), then you need time for deleting items for categories (plus, GC also takes time), populating the list with the values for subcategories. The weak points here that the user cannot return to the previous Activity using back button (this violates the default flow for user interactions), the screens are identical for categories and subcategories (this can mess the user), it will takes a long time for deleting unnecessary elements and populating with new elements. Strong point: you will reduce memory consumption for your application.
- The second option is to use different activities. Weak points: it also takes time to initialize new activity and to populate the list with the values of subcategories, it will take more memory to store two activities. Strong point: clear user understanding, more responsibility to user's actions (you do not need to run GC to delete unnecessary objects).
As for me the second approach is better unless you are not restricted with the memory.
Post a Comment for "In Android What Is Efficent Way For Use Of Activity"