Introduction to Android Development

Similar documents
Android Application Development. By : Shibaji Debnath

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Multiple Activities. Many apps have multiple activities

Introduction To Android

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Our First Android Application

Mobile Software Development for Android - I397

CSCU9YH Development with Android

Android UI Development

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Embedded Systems Programming - PA8001

Introduction to Android

INTRODUCTION TO ANDROID

Real-Time Embedded Systems

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING Android Services

Android Overview. Most of the material in this section comes from

App Development for Android. Prabhaker Matet

Fragment Example Create the following files and test the application on emulator or device.

Introduction to Android

Questions and Answers. Q.1) Which of the following is the most ^aeuroeresource hungry ^aeuroepart of dealing with activities on android?

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Create Parent Activity and pass its information to Child Activity using Intents.

Android Application Development

Getting Started With Android Feature Flags

Android HelloWorld - Example. Tushar B. Kute,

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

Mobile OS. Symbian. BlackBerry. ios. Window mobile. Android

Another difference is that the kernel includes only the suspend to memory mechanism, and not the suspend to hard disk, which is used on PCs.

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

Android - JSON Parser Tutorial

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Introduction to Android Android Smartphone Programming. Outline University of Freiburg. What is Android? Background University of Freiburg.

Introduction to Android

Getting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento

Security model. Marco Ronchetti Università degli Studi di Trento

MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

Android - Widgets Tutorial

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

Applications. Marco Ronchetti Università degli Studi di Trento

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

INTENTS android.content.intent

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

An Overview of the Android Programming


Android System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015

Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]

Fragments. Lecture 11

Mobile Programming Lecture 1. Getting Started

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

ANDROID PROGRAMS DAY 3

Android Development Tutorial. Yi Huang

Produced by. Mobile Application Development. Eamonn de Leastar

Android App Development. Muhammad Sharjeel COMSATS Institute of Information Technology, Lahore

Android App Development. Ahmad Tayeb

Computer Science E-76 Building Mobile Applications

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Mobile Programming Lecture 5. Composite Views, Activities, Intents and Filters

Android. Lesson 1. Introduction. Android Developer Fundamentals. Android Developer Fundamentals. to Android 1

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android. Operating System and Architecture. Android. Screens. Main features

COMP4521 EMBEDDED SYSTEMS SOFTWARE

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

Introduction. Lecture 1. Operating Systems Practical. 5 October 2016

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android. Emmanuel Agu

ANDROID SYLLABUS. Advanced Android

Application Fundamentals

Android Beginners Workshop

CS 528 Mobile and Ubiquitous Computing Lecture 1b: Introduction to Android. Emmanuel Agu

Android User Interface Android Smartphone Programming. Outline University of Freiburg

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Tabel mysql. Kode di PHP. Config.php. Service.php

Required Core Java for Android application development

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

LifeStreet Media Android Publisher SDK Integration Guide

Solving an Android Threading Problem

Mobile Application Development Android

Android Online Training

A Crash Course to Android Mobile Platform

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Minds-on: Android. Session 1

EMBEDDED SYSTEMS PROGRAMMING Android NDK

Android for Java Developers Dr. Markus Schmall, Jochen Hiller

COMP61242: Task /04/18

The World of Android Development

Android App Development

Android User Interface

Android App Development

Android Tutorial: Part 3

Mobile Development Lecture 8: Intents and Animation

Transcription:

Introduction to Android Development

What is Android? Android is the customizable, easy to use operating system that powers more than a billion devices across the globe - from phones and tablets to watches, TV, cars and more to come. (https://www.android.com/) Based on the Linux kernel 2008 2017: Latest release 7.1.2 "Nougat" Android Inc. Google Open Handset Alliance Competitors: Apple ios, Microsoft Windows Programming: C, C++, Java

Java Applications on Android Java bytecode dex-code (Dalvik Executable) Android application package (APK) Until version 5.0, Android used Dalvik as a process virtual machine with trace-based just-in-time (JIT) compilation to run Dalvik "dex-code". Android Runtime (ART) is the new runtime environment, which uses ahead-of-time (AOT) compilation to entirely compile the application bytecode into machine code upon the installation of an application. http://developer.android.com/ Android Studio

The Main Components Activity An email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails Service A service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction. Content Provider (file system, SQLite,...) For example, the Android system provides a content provider that manages the user s contact information Broadcast Receiver For example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured.

Create a Project with Android Studio /HelloWorld/app/src /main /test /java /res /com/example/mainactivity.java /layout activity_main.xml /drawable /values /... AndroidManifest.xml /HelloWorld/app/libs /HelloWorld/app/build Java definition of the source classes XML files describing the user interface Images and other graphical resources String and color definitions The manifest file describes the fundamental characteristics of the app and defines each of its components.

Hello World!

The Application Components MainActivity.java DisplayMessageActivity.java res/layout/activity_main.xml res/layout/activity_display_message.xml res/values/strings.xml AndroidManifest.xml gen/r.java

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout... tools:context="com.example.helloworld.mainactivity"> <TextView android:text="@string/your_name" android:id="@+id/textview"... /> <EditText android:inputtype="textpersonname" android:text="" android:id="@+id/inputname"... /> <Button android:text="@string/say_hello" android:id="@+id/button" android:onclick="sendmessage".../> The + (plus) symbol indicates that we are creating the new resource name and it must be created and added in to R.java R is the class containing the definitions for all resources of a particular application package. </RelativeLayout>

strings.xml A string resource provides text strings for your application with optional text styling and formatting. <resources> <string name="app_name">helloworld</string> <string name="your_name">your name</string> <string name="say_hello">say Hello!</string> <string name="message">hello %1$s!</string> <string name="title_activity_main">mainactivity</string> </resources>

MainActivity.java public class MainActivity extends Activity { @Override protected void oncreate(bundle savedinstancestate) { //the bundle contains the activity's previously frozen state super.oncreate(savedinstancestate); } setcontentview(r.layout.activity_main); R is the class containing the definitions for all resources of a particular application package. } public void sendmessage(view view) { } Intent intent = new Intent( Specifies an explicit intent this, DisplayMessageActivity.class); EditText inputname = (EditText) findviewbyid(r.id.inputname); String name = inputname.gettext().tostring(); intent.putextra("name_key", name); startactivity(intent);

Android Activity class An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setcontentview(view). While activities are often presented to the user as fullscreen windows, they can also be used in other ways: as floating windows or embedded inside of another activity. The Activity class is an important part of an application's overall lifecycle, and the way activities are launched and put together is a fundamental part of the platform's application model.

Android Intent class An intent is an abstract description of an operation to be performed. It can be used with startactivity to launch an Activity, broadcastintent to send it to any interested BroadcastReceiver components, and startservice or bindservice to communicate with a background Service. An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.

Explicit vs. Implicit Intents Explicit Intents have specified a component which provides the exact class to be run. Implicit Intents have not specified a component; the system will determine which of the available components is best to run for that intent. Intent resolution: maps an Intent to an Activity, BroadcastReceiver, or Service (or sometimes two or more activities/receivers) that can handle it. Example: Opening a Web Page Intent myintent = new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); startactivity(myintent);

activity_display_message.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout tools:context="com.example.helloworld.displaymessageactivity"> <TextView android:id="@+id/textview" android:layout_alignparenttop="true" android:layout_margintop="67dp" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparentright="true" android:layout_alignparentend="true" /> </RelativeLayout>

DisplayMessageActivity.java public class DisplayMessageActivity extends Activity { @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); Intent intent = getintent(); String name = intent.getstringextra("name_key"); //Create the message from the resource bundle String message = getstring(r.string.message, name); //Let's not use the xml layout (just for fun) //setcontentview(r.layout.activity_display_message); TextView textview = new TextView(this); textview.settext(message); } } // Set the text view as the activity layout setcontentview(textview);

Drawing public class GraphicsView extends View { public GraphicsView(Context context){ super(context); } protected void ondraw(canvas canvas) { super.ondraw(canvas); int w = canvas.getwidth(); int h = canvas.getheight(); Paint paint = new Paint(); paint.setcolor(color.white); canvas.drawpaint(paint); paint.setantialias(true); paint.setstyle(paint.style.fill); } } Random rnd = new Random(); for (int radius = w/2; radius >0; radius -= 10) { int color = Color.argb(255, rnd.nextint(256), rnd.nextint(256), rnd.nextint(256)); paint.setcolor(color); canvas.drawcircle(w/2, h/2, radius, paint);

androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloworld"> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity" android:label="@string/title_activity_main" android:exported="true" android:theme="@style/apptheme.noactionbar"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name = "android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".displaymessageactivity" /> <activity android:name=".graphicsactivity"></activity> </application> </manifest>

Set up your device Run on a Real Device Settings About tap Build number 7 times Enable USB debugging on your device, by going to Settings Developer options. Run the app from Android Studio In the Choose Device window that appears, select the Choose a running device radio button, select your device Install the app on your device Build signed.apk using Android Studio Settings Security Enable 'Unknown Sources' Copy the.apk to your device and tap it to install (use a file manager)

Next Steps... User Interface Resources Animation and Graphics (OpenGL) Computation (Renderscript) Media and Camera Location and Sensors Connectivity Text and Input Data Storage,etc.