Xamarin: Android Activities, Context, Intents and Views |
If you are coming from C#/Silverlight, Android can be a little diffusing. Android does not have the same structure than a Windows or Windows Phone app. Activities Android has Activities. Activities are the key classes of Android were all actions take place. Unlike other apps or programs, you do not have a "Main" program that is your starting point when launched. In Android, the starting point is an Activity. The Activity needs to be declared as the starting point. When you start a new project in Xamarin, an Activity called "MainActivity" gets created automatically. This Activity has some attributes: [Activity (Label = "gettingstarted", MainLauncher = true)] The 'Label' attribute is what you will see in the Title bar when launching the app. The attribute 'MainLauncher=true' tells the application to start from here. Think of this as your MainPage.xaml.cs in a Windows Phone app. Every Activity has its own OnCreate event, where you can put all your starting, button handlers, stylings etc.