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

Hello Android

Joe Rowley
February 22, 2016

Hello Android

From zero to your first Android application. The very basics to get you running.

Joe Rowley

February 22, 2016
Tweet

More Decks by Joe Rowley

Other Decks in Programming

Transcript

  1. github.com/alphonzo79/HelloAndroidExample

  2. Course Goals o Know the tools needed for Android development

    o Basic understanding of what makes up an Android application o Basic understanding of using and modifying elements at run time. o Basic understanding of navigating around an app o Have a feeling for what questions to ask when you get into the thick of it
  3. What we will NOT Cover o Setting up your IDE

    and creating the project o IntelliJ IDEA (Community Edition), Android Studio, Eclipse, etc (USE ANDROID STUDIO) o Most IDEs have a good wizard for creating the project and this is really quite simple. o Plenty of online tutorials. o Downloading and installing the JAVA JDK o Any recent version of Java SE (<1.8) will do o Downloading and installing the Android SDK
  4. Setting Up Android (Quickly) o Make sure your environment variables

    are set up o $ANDROID_HOME:<Where I installed Android>/sdk o Make sure your PATH includes o $ANDROID_HOME o $ANDROID_HOME/platform-tools o $ANDROID_HOME/tools o $ANDROID_HOME/bin o Install necessary API level(s) o From the command line run $ android sdk o Or launch from your IDE
  5. Setting Up Android (Quickly) o Set up an emulator o

    From the command line run $ android avd o Or launch from your IDE o USE GENYMOTION – Mac and Linux require Oracle VirtualBox to be installed first o Attach your USB phone o Turn on Developer Options in settings o There may be a trick for your phone, check Google (click build number 7 times) o Enable USB Debugging, accept certificate warnings o Double check – run $ adb devices
  6. Setting Up Android (Quickly) o Set up Gradle (If you

    want) o Current version is 2.+ o Add <gradle_home>/bin to your $PATH o Or, AndroidStudio takes care of it for you
  7. Project Structure and Basic Components o Activities (And Fragments) o

    We will see plenty of these. Just a mention for now o We may or may not touch on Fragments, depending on time o Services o Long-Running (it's a relative term) background tasks o Should always be run on their own threads o You need to put them on their own thread
  8. Project Structure and Basic Components (Continued) o Broadcast Receivers o

    Register with Android to be notified of certain events and to receive certain intents o Content Providers o Means for sharing data between processes o Intents o Not necessarily a component, but very integral to all of them and how they are launched o We will see several of these
  9. Project Structure and Basic Components (Continued) o Resources o Drawables,

    Layouts, Values (Strings, Colors, etc). o Allows us to provide a variety of alternate resources outside of code o Directory modifiers o Android Manifest o SDK data (min, max, target), Permission data, Application data, Launcher data, etc o A lot of this has since been moved into build.gradle
  10. Project Structure and Basic Components (Continued) o Android Manifest (Continued)

    o All activities, services, and other components o If it's not in the manifest it doesn't exist o Gradle o settings.gradle o Manage project structure (included modules) o build.gradle (top level) o Manage project-wide build. This often just declares the Maven central repository and the classpath for the Android gradle plugin
  11. Project Structure and Basic Components (Continued) o Gradle (Continued) o

    build.gradle (Module level) o Manage build for the module o Android Plugin (and others if applicable) o MinSDK, TargetSDK declarations o Versioning o Manage dependancies (Maven-style) o Manage build types and flavors o Android Studio will set it all up for you for a basic project
  12. A Very Basic App o Create two files (The wizard

    will do this for us): o src/example/hello_android/MainActivity.java o res/layout/main_activity.xml o Set up manifest (Thank you wizard!) o Declare the main activity and make it launchable o Activity o Lifecycle and Overridable Lifecycle Events o onCreate – Tell the activity which layout to use o Launch it.
  13. Expand the App A Little o Use string resources o

    Add some more controls o TextView, EditText, Button o Find the controls and interact with them o Add onClickListeners o Three different ways to do this (At least) o Access and read properties o Modify the text in a TextView at runtime
  14. Expand the App Again o Add another activity o Add

    some intents to a couple of the buttons o Explicit Intent o Declare the target class o Bundle some extras to pass data between activities o Consume the intent on the other end o Implicit Intent o Declare the desired action and the data URI o Let Android manage where the intent get delivered
  15. Resources o Java JDK: http://www.oracle.com/technetwork/java/javase/downloads/inde x.html o Android SDK: https://developer.android.com/sdk/index.html

    o Android Studio: http://developer.android.com/sdk/installing/studio.html o Android Documentation (Training, API Guides, Reference, tools, etc): https://developer.android.com/training/index.html