Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & Android Activity Lifecycle

Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & Android Activity Lifecycle

Introduces you to Xamarin.Android development. In this class we will examine the tools you will use, Xamarin.Android projects, and Android fundamentals that every developer needs to know to be successful in building Android apps!

Cheah Eng Teong

April 30, 2017
Tweet

More Decks by Cheah Eng Teong

Other Decks in Programming

Transcript

  1. Learn Xamarin Absolute Beginners Application Manifest, Android Resources & Android

    Activity Lifecycle Eng Teong Cheah Microsoft MVP in Visual Studio & Development Technologies
  2. Application Manifest All Android Apps have a manifest file commonly

    referred to as AndroidManifest.xml. The manifest file contains everything about the Android platform that an App needs in order to run successfully.
  3. Application Manifest Application name – It refers to the title

    of your App Package name – It is a unique name used to identify your App Application Icon – It is the icon displayed on the Android home screen for your App.
  4. Application Manifest Version Number – It is a single number

    that is used to show one version of your App is more recent than other. Version Name – It is a user-friendly version string for your App that users will see on your App settings and on the Google PlayStore. The following code shows an example of a version name. <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" > <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0.0">
  5. Application Manifest Minimum Android Version – It is the lowest

    Android version platform which your application supports. In the above example, our minimum Android version is API Level 16, commonly referred to as JELLY BEAN. Target Android Version – It is the Android version on which your App is compiled against. <uses-sdk android:minSdkVersion="16" />
  6. Android Resources When a new Android project is created, there

    are some files that are added to the project, by default. We call these default project files and folders as Android Resources. Take a look at the following screenshot.
  7. Android Resources The default Android resources include the following -

    AndroidManifest.xml file – It contains information about your Android applications, e.g. the application name, permissions, etc. Resources folder - Resources can be images, layouts, strings, etc. that can be loaded via Android’s resource system.
  8. Android Resources Resources / drawable folder – It stores all

    the images that you are going to use in your application. Resources / layout folder -It contains all the Android XML file (.axml) that Android uses to build user interfaces. The Resources / value folder - It contains XML files to declare key- value pairs for strings (and other types) throughout an application. This is how localization for multiple languages is normally set up on Android.
  9. Android Resources Resources.designer.cs – This file is created automatically when

    the Android projected is created and it conatins unique identifiers that reference the Android resources. MainActivity.cs file - This is the first activity of your Android application and from where the main application actions are launched from.
  10. Android Resources Resource files can be accessed programmatically through a

    unique ID which is stored in the resources.designer.cs file. The ID is contained user a class call Resource. Any resource added to the project is automatically generated inside the resource class.
  11. Android Activity Lifecycle When a user navigates through an Android

    App, a series of events occurs. For example, when a user launches an app, e.g. the Facebook App, it starts and becomes visible on the foreground to the user, onCreate( ) -> onStart( ) -> onResume( ).
  12. Android Activity Lifecycle If another activity starts, e.g., a phone

    call comes in, then the Facebook app will go to the background and the call comes to the foreground. We now have two processes running. onPause() --- > onStop()
  13. Android Activity Lifecycle When the phone call ends, the Facebook

    app returns to the foreground. Three methods are called. onRestart() --- > onStart() --- > onResume()
  14. Android Activity Lifecycle There are 7 lifecycle processes in an

    Android activity. They include – onCreate – It is called when the activity is first created. onStart – It is called when the activity starts and becomes visible to the user. onResume– It is called when the activity starts interacting with the user. User input takes place at this stage.
  15. Android Activity Lifecycle onPause – It is called when the

    activity runs in the background but has not yet been killed. onStop – It is called when the activity is no longer visible to the user. onRestart - It is called after the activity has stopped, before starting again. It is normally called when a user goes back to a previous activity that had been stopped.
  16. Android Activity Lifecycle onDestroy – This is the final call

    before the activity is removed from the memory.