Ive been doing some reading, and got a little confused. In Android development, is there a difference between a Screen and an Activity? What are they? I was reading about an Activity having multiple screens.
Ive been doing some reading, and got a little confused. In Android development, is
Share
An activity is a piece of your application which should handle a single specific task (example, receive input from the user or display images or whatever you want).
The part you are referring, “supporting multiple screens” can be explained as a best practice you should follow when developing your application: this is simply the designing of proper layouts based on different possible screen sizes and densities. There is nothing such a “Screen” class in android.
So the relationship between an Activity and the moltitude of screen sizes out there is mapped by the layout XMLs defined in the proper layout folders in your application. The android OS will choose and handle the layout for your activity based on the hardware screen available and the closest-to-best layout you defined.
Think of an activity as a “window” on a desktop OS (like Windows7 or MacOSX or Ubuntu) that allows you to see only one window at a single time. If you have 10 different activities in your app the user may see up to 10 different windows. The android OS will pick the most compatible layout you defined based on the real screen display the user has and places the GUI component accordingly.