Android Programming

Mahmoud Hammad Introduction

• Android provides a rich framework that allows you to develop innovative Apps • Android Apps are developed in and run on Android-powered devices • There are many IDEs that support building Android Apps • Tow main resources to learns Android programming • Android developer documentation: https://developer.android.com/index.html • Open source repositories: learn from others’ code • AOSP (Android Open Source Project) • F-Droid • … Outline

• Android Development Environment • Android Platform • Android App Fundamentals • Building Android App • Open Source Apps Android Development Environment

(JDK) • Check if you have it ($ java –version). If not, download it from Oracle • Android Development Kit (SDK) • Set of tools and the Android framework to develop and build an App • Integrated Development Environment (IDE) • with Android Development Tool (ADT) • : All-in-One IDE, powered by Intellij IDE • Emulator to run and test your App • Android Virtual Device (AVD): created by AVD Manager which is part of the SDK • Genymotion: Very fast emulator runs on Oracle VirtualBox Time to download Android Studio version 2.2

• https://developer.android.com/studio/index.html • Requires 1.6 GB Disk space and 2GB of RAM Android Platform Architecture

• Android System is a multi-user -based • App runs in an instance of a VM called: • ART for Android 5.0 (API level 21) and after • Android App Fundamentals • App components: ➢Activity ➢Service ➢Broadcast Receiver ➢Content Provider • Each App runs in a process with a unique Linux user ID, for that • Apps can not communicate with each other • Apps can not access system resources (Camera, Location Sensor, etc) • To solve the aforementioned issues, Android developed: • Inter-Component communication mechanism (ICC) o Intent: A messaging object to request an action from another component either explicitly or implicitly • Permission system: System permission and custom permission • Android SDK compiles the Apps into Android Packages (APK ) Let’s build an App!

Activity Broadcast Receiver Activity

You have successfully [U] Make a Toast to Username: ___U___ logged in. welcome the user. {A2} Password : ___ P___ [U] {MAIN} Valid Login

Invalid [U, P] Activity Service [U, P, Username and DeviceID] Logs username, password do not password, and device {A1} match. {A3} ID to the system log.

Explicit Intent Implicit Intent Component [Intent Extra Data] {Action} Intent Filter Open-Source App

• Many open-source Apps developed using Eclipse-ADT • To import an Eclipse-ADT project to Android Studio, follow the migration steps described here • Let’s migrate an App: • Download an open-source App from F-Droid • Migrate the App to Android Studio IDE • Explore the App • Build the App • Run it! Any Question?