Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Android Programming

Similar presentations


Presentation on theme: "Introduction to Android Programming"— Presentation transcript:

1 Introduction to Android Programming

2 Contents Basic Concepts Environment Setup
Creating and Building Android App

3 Android Android apps are written in Java
The Android OS is a multi-user Linux system Android app lives in its own security sandbox System assigns each app a unique Linux user ID Each process has its own virtual machine Every application runs in its own Linux process

4 Application Components
Android Application .apk : Android package Four Application Components Activity Service Content Provider Broadcast Receiver Communication among components except Content Provider Intent extension

5 Activity Activity Lifecycle Implement Lifecycle Callbacks

6 Activity Start an Activity Start an Activity for a Result
Caller Activity Callee Activity

7 Activities and Stack

8 Services A service is a component that runs in the background to perform long-running operations A service does not provide a user interface Activity can start the service and let it run or bind to it in order to interact with it e.g., a service might play music in the background while the user is in a different app

9 Broadcast Receivers A broadcast receiver is a component that responds to system-wide broadcast announcements Apps can also initiate broadcasts Although broadcast receivers don't display a UI, they may create a status bar notification to alert the user when a broadcast event occurs

10 Content Providers A content provider manages a shared set of app data
Through the content provider, other apps can query or even modify the data Any app with the proper permissions can query part of the content provider

11 Intent An intent is an abstract description of an operation to be performed startActivity sendBroadcast startService (bindService)

12 Environment Setup Step 1: Install JDK

13 JDK Installation Can download the JDK for your OS at Alternatively, OS X: Open "Terminal” Type javac at command line Install Java when prompt appears Linux: Type sudo apt–get install default–jdk at command line (Debian, Ubuntu) Other distributions: consult the documentation JDK and JRE are different!

14 Environment Setup Step 2: Configure the Android SDK

15 SDK Configuration Download Android SDK from Or Simplest: Download and install Android Studio bundle (including Android SDK) Software development kit

16 Eclipse IDE- Official IDE for Android development
Integrated development environment Eclipse IDE- Official IDE for Android development Apache Ant for building projects

17 Android focused IDE, designed specifically for Android development.
Contains all SDK tools for develop, debug, or test.

18 Android Studio Android Development Environment based on IntelliJ IDEA
Software development kit

19 Android Studio Android uses Gradle
Gradle is an open source build system that combines the power of Ant and Maven Software development kit

20

21 Android Studio Software development kit

22 Run Android SDK Manager
Recommended: Install Android 2.2, APIs and 4.x API Do not worry about Intel x86 Atom, MIPS system images Settings

23 Now you are ready for Android development!

24

25 Create New Android Project

26

27 Create Activity

28

29

30 The Manifest File Identify any user permissions the application requires Declare the minimum API level required by the application Declare hardware and software features used or required by the application API libraries the application needs to be linked

31 The Manifest File

32 The Manifest File Do not forget to declare Components in the Manifest

33 Permission Add following permissions to the Manifest file

34 Sample Code

35 UI – Declaring Layout Initiated when called setContentView() on onCreate() Use Visual Layout Editor for initial layout design Edit XML file extensively

36 Editing Sample Code “@+id/helloId” Add id to main.xml
Edit HelloWorldActivity.java

37 A Sample Code Important points UI Element has an Id
Variables in our code link to UI elements Update UI element content from the program 1 2 Hello world! 3

38 UI – Handling UI Events onClick, onLongClick, onKey, onTouch, …

39 Sample Implementation
MainActivity Option menu Context menu Capture Play click CaptureActivity Upload Service Capture Button Click PlayerActivity Background Upload

40 Building Process Running

41 Running Sample App

42 App Failure

43 Debugging, look at DDMS !!! “Dalvik Debug Monitor Service”

44 Enabling USB Debugging

45 Thank You! Any questions
*These slides are based on the slides from


Download ppt "Introduction to Android Programming"

Similar presentations


Ads by Google