Intro to Android Programming George Nychis Srinivasan Seshan.

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Android OS : Core Concepts Dr. Jeyakesavan Veerasamy Sr. Lecturer University of Texas at Dallas
Introduction to Android Mohammad A. Gowayyed CS334-Spring 2014.
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna.
Android Tools & Wireless ADB Αντρέας Λύμπουρας Θεόφιλος Φωκάς Ζαχαρίας Χ’’Λάμπρου.
Advanced Android Programming George Nychis Srinivasan Seshan.
Android 02: Activities David Meredith
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
PROJECT IN DISTRIBUTED SYSTEMS IPERF FOR ANDROID Developers: Shir Degani, Yuval Degani Supervisors: Prof. Roy Friedman, Alex Kogan.
Android and Project Structure. Android Android OS – Built on Linux Kernel – Phones – Netbooks – Readers – Other???
Version Control Systems Phil Pratt-Szeliga Fall 2010.
Mobile Application Development
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Android Tutorial Android Written in Java Utilizes Dalvik VM – Just in time (JIT) compilation since Android 2.2.
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Android Application Development 2013 PClassic Chris Murphy 1.
CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle.
Android Introduction Platform Overview.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Android and Eclipse Thaddeus Diamond CPSC 112. A Quick Introduction Eclipse is an IDE (Integrated Development Environment Open Source Much more full-featured.
Programming Your Android App Gourav Khadge
Mobile Application Development with ANDROID Tejas Lagvankar UMBC 29 April 2009.
Mobile Application Development with ANDROID. Agenda Mobile Application Development (MAD) Intro to Android platform Platform architecture Application building.
About me Yichuan Wang Android Basics Credit goes to Google and UMBC.
Introducing the Sudoku Example
CS5103 Software Engineering Lecture 08 Android Development II.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Take a leap towards the most promising technology
Android Info mostly based on Pro Android 3.  User Applications  Java Libraries – most of Java standard edition ◦ Activities/Services ◦ UI/Graphics/View.
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
01. Introduction to Android Prof. Oum Saokosal Master of Engineering in Information Systems, South Korea
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
Java Android-8 Imran Shafi. Lecture Contents  Debugging Android Projects  Java/XML Errors  Debugger  Logcat Utility  Android Debug Bridge (adb) 
Basic Android Tutorial USF’s Association for Computing Machinery.
ANDROID Presented By Mastan Vali.SK. © artesis 2008 | 2 1. Introduction 2. Platform 3. Software development 4. Advantages Main topics.
CSE 403 Section: SRS and Use Cases January 14, 2010.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
Android for Java Developers Denver Java Users Group Jan 11, Mike
10/10/2015 E.R.Edwards 10/10/2015 Staffordshire University School of Computing Introduction to Android Overview of Android System Android Components Component.
Working in the Background Radan Ganchev Astea Solutions.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
1 Android Introduction Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
1 Android Workshop Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
By: Collin Molnar. Overview  Intro to Android  Security basics  Android architecture  Application isolation  Application permissions  Physical access.
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
Android. Android An Open Handset Alliance Project A software platform and operating system for mobile devices Based on the Linux kernel Developed by Google.
Introduction to Android Programming
Android Mobile Application Development
Android 01: Fundamentals
Reactive Android Development
Android Studio, Android System Basics and Git
Android.
Development-Introduction
CMPE419 Mobile Application Development
Android training in Chandigarh. What is ADB ADB stands for Android Debug Bridge. It is a command line tool that is used to communicate with the emulator.
Android Programming Lecture 9
CS5103 Software Engineering
Application Development A Tutorial Driven Course
Android Topics Asynchronous Callsbacks
Android Platform, Android App Basic Components
Emerging Platform#3 Android & Programming an App
Android Development Introduction to Android Development 2011/01/16
CMPE419 Mobile Application Development
Presentation transcript:

Intro to Android Programming George Nychis Srinivasan Seshan

Over the next two lectures… Use these lectures as a reference, in addition to documentation Today: A higher level overview and the basics Application and interface basics Application and hardware permissions (“Android Manifest”) How to multi-thread on Android (“AsyncTask”) How info is passed between threads, interface, HW (“Intents”) Next Week: Advanced topics on Android Persistent application storage (Preferences, Database) Writing and linking non-Java code (e.g., C and C++) Cross-compiling useful libraries to Android Modifying the kernel (e.g., to add support, remove permissions) USB host support (to access external peripherals)

Quick Overview Architecture: ARM OS: stripped down version of Linux E.g., Full linux kernel, but custom libraries (libc, libpthread…) Programming Language: Java with some customization Applications are run in Dalvik VM for isolation, optimization Android SDK vs. NDK SDK: build main application code and interface NDK: toolset to build/port “native” code and libraries in C/C++

ADB: Android Debug Bridge ADB command line tool and program that: Has a client on your development machine (“adb”) Runs a server on your development machine Runs a daemon on your development device (i.e., phone/tablet) ADB is what gets your code from machine to device, and sets up a bridge for true debugging (step by step) on device Some useful “adb” commands: adb devices – shows your currently connected devices adb connect xxx.xxx.xxx.xxx – connect to device wirelessly adb shell – opens up a terminal/shell on your device adb push -- send to folder on device adb pull -- get from dev, save to…

Application Basics Activities: single focused user interaction, mainly for UI Typically used to create a full screen windows, dialogues Activities run on their own thread Any code that runs on the UI thread will lock up the UI! Main “work” should be done in threads (we will get to this…) Activities go through a basic “life cycle” that is important…

Activity “Life Cycle”

Creating an Activity For each activity, you need…. 1) A Java declaration of the activity:

Activity Layouts Can grab and drag these Easiest to modify items (and some of layout) in the XML file

Activity Layout XML Can add actions and change properties Create corresponding code to run on the click action

Close Activity, Open Another 1.Create a new “Intent” 2.Start the new Activity 3.Call “finish()” to destroy the current activity Instance of current Activity Class of new Activity

Going “Back” in Activities Two ways to go “backwards” in activities: 1.Dictate exactly what Activity should show up 2.Don’t call “finish()” when opening new Activity, then on back button click just closes new Activity, old should be back in focus Method 2: Just “pop” the current Activity off stack Method 1: Dictate the Activity that should be started

Android Manifest Critical part of your entire application, it defines: Hardware application has permission to access Information the application can access/modify Defines all activities in the application A single AndroidManifest.xml per application Skeleton generated when creating new application Ordering of items and embedding of declarations is important Order: Permissions,, Activities, Useful link for permissions: rmission.html rmission.html

Example Manifest

The Importance of Threading This will stall execution of the main UI thread, locking interface: Do not run “tasks” on your main UI thread!

Multithreading 2 main ways to achieve “code” that doesn’t run on UI thread 1.AsyncTask (custom pthread wrapper) 2.Background service (which you send requests to) Critical: you can only modify the UI on the UI thread! If you try to modify it from another thread, you will get an exception and application will crash AsyncTask: most commonly/easily used Provides callback on UI thread when complete, allowing you to update UI thread afterwards

Runs before thread executes (UI Thread) Runs after onPreExecute() (New Thread) On every publishProgress() (UI Thread) After doInBackground() completes (UI Thread)

Broadcast Intents Android “broadcasts” information between services/threads Used to receive information from services, hardware, sensors… Used to pass information between threads For example, you do not “query” accelerometer or GPS sensors You register a broadcast receiver to “catch” their broadcast info Android is smart: if nothing registered to receive the information, the sensor is disabled You’ll better understand this with some examples…

Accelerometer Example Accelerometer is always “alive” but is not pollable and does not send out information unless it knows something wants it A thread registers for the information, Android is smart and only when something is registered, it “broadcasts it” This means, if some other application is requesting accelerometer data you can read it simply by listening for the broadcasts, but not guaranteed to get it unless you register.

Other Examples GPS: You either tell system to give you updates every X milliseconds, or you can request a single reading Response is still broadcast throughout entire system… think: other applications can opportunistically use the data Wifi: You can request an AP scan, result is broadcast (again) throughout entire system, you listen for the result. Threads: You can create your own broadcast intents and listeners, and your threads can “broadcast” results to other threads in your application.

Broadcast Intent Example - Pt1 Broadcasts are labeled by “actions” which are Strings: You register a receiver for a specific action which must be tied to an Activity, so it is commonly done in onResume() Must unregister when Activity is paused/destroyed, otherwise it is “leaked” and you will get an exception:

Broadcast Intent Example - Pt2 You then must create the receiver that you just registered Check that the incoming action equals what you’re looking for Data passed with the action (e.g., sensor data) will always be with the Intent

Broadcast Intent Example - Pt3 Next, you create a Broadcast which is sent, which in our example we broadcast after our Thread completes: Extras can be put in the “Intent” but it cannot be arbitrary objects. You can extend arbitrary objects to be marshaled in out of intents with “Parcelable”

Wrap-up Code is available on github for you to run in the Emulator or directly on your phone: Feel free to ask me questions: Next week we will touch on the more advanced topics Anything you want to hear about, me and I’ll try to cover it