In the last Blog Post you learnt how to create device specific resources like Layout, Menu, Images etc.
On a phone the Employee App will display list of Employees initially and on click of an employee the DetailActivity will be called. Whereas on a Tablet the List and the Detail is shown next to each other.
Question is how to achieve this?
If you take a look at the Layout XML file you will find that for a Tablet you have a FrameLayout.
So you can check in the Activity class that if this attribute exists then its a tablet. If not then call the DetailActivity.
Let’s look at the MainActivity class. The MainActivity class is called when you Launch the App.
This Class is an Activity. Now you might be wondering what is an Activity. An Activity is used to peform certain basic setup tasks when the App Launches. Like specify the Layout
which the App will use. All activities should extend Activity class and implement the onCreate method which gets called when the activity object gets created.
I hope this gives you an idea about the MainActivity Class. We will look at the activity life cycle a little later. In the next video you will see the Layout file. Until next time, bye.