Android

From ◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞◜◝◟◞
Jump to: navigation, search

CE Learning

  1. Complete Nougat
  2. Android Basics: User Interface
  3. Firebase in a Weekend

Glossary

Glossary of Terms]

New Project Configuration

Application Name

Space, capital letters, i.e. "Demo App"

Company Name

domain name i.e. "example.brandonphuong.net" Doesn't really matter that much at this point. All of this configuration can be changed later. All that really matters is that this config builds the package name.

Package Name

Package Nameː company domain and application name in reverse i.e., "net.brandonphuong.example.demoapp"

Package name is used if your package is submitted to Google Play, so it must be unique. The package name removes spaces, capitals, etc.

Folder Tree

2 main folder which should concern you.

Gradle

Gradle is an OS build tool inside Android Studio application which AS uses to build from files in the folder tree. The gradle folder are just scripts. If we want, we can write scripts to customize work in the build process.

App

A collection of folders and files which make up your Android Application. 3 folders exist my default: manifests, res and java

Manifests

AndroidManifests.xml contain basic details about our app, such as application icon, labels, app name, app theme, etc. Edit this later on.

Res

Short for resources, contains things such as images, icons, or music our application needs. Inside res > layout > activity ̠ main.xml, this is where we'll see what it actually looks like.

Java

This is where our main source code lives and runs. MainActivity file inside Java is where we:

  • define our package (basically the package name)
  • can import classes, or, bundles of codes.
    • The first is android.support.v7.app.AppCompatActivity, compat is short for compatiblity, which makes sure our app is backwards compatible with as many android versions as possible.
    • The second is android.os.Bundle, which is the operating system bundle, that allows us to work with the Android OS.
    • And then, public class allows us to define our own class. In this example, we're defining MainActivity

Activity & Layout Name

Activity name is self explanatory, however it is without spaces, words , by default:MainActivity

Layout name is in reverse and separated by underscore, i.e, activity_name

Minimum SDK

Choose API 15 Android 4.0.3(IceCreamSandwich), or whichever will be most compatible with your target devices.

Android Activity Lifecycle

Activity Lifecycle

In Android OS, almost all apps start and end with an activity.

Activities get created, paused, stopped and destroyed. These lifecycle changes need to be handled gracefully.

There are many lifecycle methods.

Android OS is responsible for recreating the activity, therefore the developer is only responsible for saving and restoring the activity state.

For example, when screen orientation changes, activities are stopped and recreated. This is because orientations require different layouts and those layouts require different resources, activities are always recreated on an orientation change. By default, if you rotate the screen, an activity will be restarted, however if you hook into the right lifecycle events, we can save off the position when the activity stops and restore that position when it gets recreated, creating the illusion of seamlessness.

Saving Instance State

Density Independent Pixels

DP, pronounced 'dip' describes an attribute value of size results in a physical size that remains consistent across all devices regardless of varying pixel density. It's reccomended that all touch targets are at least 48x48dp.

Use AWS

closing tag

camelcase