Introduction to Android and Android Studio

60
INTRODUCTION TO ANDROID AND ANDROID STUDIO Suyash Srijan

Transcript of Introduction to Android and Android Studio

Page 1: Introduction to Android and Android Studio

INTRODUCTION TO ANDROID AND ANDROID STUDIOSuyash Srijan

Page 2: Introduction to Android and Android Studio

ABOUT THE SPEAKER• Computer science student at Oxford Brookes• A kickass Android developer with nearly 6 years of experience• Experience with building ROMs and porting Android to different devices• Experience with other platforms (iOS, Windows, Blackberry) and Wearables (Pebble & Android Wear)• Overall a very cool guy

@suyashsrijanfb.com/suyashsrijangithub.com/theblixguy

Page 3: Introduction to Android and Android Studio

WHAT WILL WE LEARN TODAY• What is Android• Why develop for Android• Android platform overview• Android app overview• Android app lifecycle• Android app fundamentals (activities, intents, etc)• Design• Device compatibility• Distribution• What we need to get started with Android development• Android Studio and development tools

Page 4: Introduction to Android and Android Studio

WHAT IS

Page 5: Introduction to Android and Android Studio

Android is the world’s most popular and dominant mobile operating system. It is based on Linux kernel 3.4/3.10 (depending on device) and is open-source (with proprietary bits). It runs on a wide variety of hardware, including smartphones, smart watches, cars, televisions, digital cameras, game consoles and more. It was founded by Andy Rubin and three others in October 2003 and got acquired by Google in August 2005.

Page 6: Introduction to Android and Android Studio

WHY DEVELOP FOR

Page 7: Introduction to Android and Android Studio

is gigantic• Over 1B users• Over 1.5M activations per day• Over 200M smartphones running Android sold annually• Over 1.43M apps available• Over 76% smartphone operating system market share

Page 8: Introduction to Android and Android Studio

is freedom• Thousands of third party libraries available• Free SDK, IDE and emulator• No restrictions; access anything*• Faster access to new form factors and hardware• Distribute your app anywhere (Playstore, Amazon Appstore, …)

* well, not anything, but you get the point

Page 9: Introduction to Android and Android Studio

PLATFORM OVERVIEW

Page 10: Introduction to Android and Android Studio
Page 11: Introduction to Android and Android Studio

APP OVERVIEW

Page 12: Introduction to Android and Android Studio

• Java: Java class files containing app logic• Res: Different resource files• Anim: Animation resource files• Drawable: Images• Drawable-Xdpi: Images depending on screen density• Layout: App layout files• Menu: Layout menu files• Values: Value files (strings, colors, arrays, etc)• Values-vX: Value files depending on API level• Values-Xdp: Value files depending on screen density• XML: XML files (duh)• AndroidManifest.xml: App metadata file• build.gradle: Build related settings

Page 13: Introduction to Android and Android Studio
Page 14: Introduction to Android and Android Studio

APP LIFECYCLE

Page 15: Introduction to Android and Android Studio
Page 16: Introduction to Android and Android Studio

APP FUNDAMENTALS

Page 17: Introduction to Android and Android Studio

ACTIVITY

Page 18: Introduction to Android and Android Studio

• A window/interface which a user can interact with

• Every app has at least one activity

• Activities can be full-screen, floating or embedded inside another activity

startActivity(new Intent(this, newActivity.class));

Page 19: Introduction to Android and Android Studio

FRAGMENTS

Page 20: Introduction to Android and Android Studio

• A piece of user interface that is meant to be reused

• Adds modularity to your app and makes dynamic UI design easy

• It has its own layout, behavior and lifecycle callbacks, but it killed/stop if the activity is too

getFragmentManager().beginTransaction().add(android.R.id.content, new MyFragment()).commit();

Page 21: Introduction to Android and Android Studio

INTENTS

Page 22: Introduction to Android and Android Studio

• An intent is an abstract description of an operation to be performed. Think of it as an “intention” to do something

• Intents can be used to start activities, services or send a broadcast

• Intents are of two types – Explicit (when you know what exactly you want to do), and Implicit (when you’re not sure what you want to do)

Intent viewAmazon = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(“http://www.amazon.com”));startActivity(viewAmazon);

Page 23: Introduction to Android and Android Studio

SERVICES

Page 24: Introduction to Android and Android Studio

• A service is a long running operation in the background

• There are two types of services in Android – Bounded (which runs as long as components which bind to it run) and Unbounded (which runs indefinitely) but a service can also be both

• Services run on the main thread of the application by default

startService(new Intent(this, myService.class));

Page 25: Introduction to Android and Android Studio

BROADCAST RECIEVERS

Page 26: Introduction to Android and Android Studio

App/

Serv

ice

System sends a broadcast

Battery level changes

SMS received

Photo captured

• A broadcast is a system or app event that can be “broadcasted” so other apps/services can listen for it

• Broadcasts are handled by a BroadcastReceiver, which is a component that allows you to listen for broadcasts

• A BroadcastReceiver can be implemented in AndroidManifest.xml, or dynamically by calling registerReceiver(), or both

• An app’s/services’s BroadcastReceiver is never called if the app/service hasn’t been explicitly started by the user

Page 27: Introduction to Android and Android Studio

CONTENT PROVIDERS/RESOLVERS

Page 28: Introduction to Android and Android Studio

App Database

Insert

Update Delete

Fetch

• A content provider allows you to store data in your app in a structured way, similar to a relational database like SQL, for the purpose of providing it to other apps. Example usage: Contacts app, SMS app, etc

• A content resolver allows you to get data from a content provider or manipulate its data (modify, delete, update, etc)

• You cannot request to read data from a content provider at runtime, it has to be declared in AndroidManifest.xml

Page 29: Introduction to Android and Android Studio

ANDROIDMANIFEST.XML

Page 30: Introduction to Android and Android Studio
Page 31: Introduction to Android and Android Studio

LAYOUTS

Page 32: Introduction to Android and Android Studio

• A layout defines the visual structure for a user interface, such as the UI for an activity or app widget

• Layouts can be defined both in XML or programmatically using View and ViewGroup objects

• There are 5 different types of Layouts in Android: LinearLayout, RelativeLayout, FrameLayout, TableLayout and AbsoluteLayout

Page 33: Introduction to Android and Android Studio

DESIGN

Page 34: Introduction to Android and Android Studio
Page 35: Introduction to Android and Android Studio

DEVICE COMPATIBILITY

Page 36: Introduction to Android and Android Studio

Android is designed to run on many different types of devices, from phones to tablets and televisions. As a developer, the range of devices provides a huge potential audience for your app. In order for your app to be successful on all these devices, it should tolerate some feature variability and provide a flexible user interface that adapts to different screen configurations. To facilitate your effort toward that goal, Android provides a dynamic app framework in which you can provide configuration-specific app resources in static files (such as different XML layouts for different screen sizes). Android then loads the appropriate resources based on the current device configuration. So with some forethought to your app design and some additional app resources, you can publish a single application package (APK) that provides an optimized user experience on a variety of devices. If necessary, however, you can specify your app's feature requirements and control which types of devices can install your app from Google Play Store.

Page 37: Introduction to Android and Android Studio
Page 38: Introduction to Android and Android Studio

DISTRIBUTION

Page 39: Introduction to Android and Android Studio
Page 40: Introduction to Android and Android Studio

WHAT DO I NEED TO BUILD ANAPP?

Page 41: Introduction to Android and Android Studio

JAVA PROGRAMMING LANGUAGE & XML

docs.oracle.com/javase/tutorial/java/

Page 42: Introduction to Android and Android Studio

ANDROID SDK & SDK TOOLSdeveloper.android.com/sdk

Page 43: Introduction to Android and Android Studio

ANDROID STUDIOtools.android.com/download/studio

Page 44: Introduction to Android and Android Studio

AND OF COURSE…

Page 45: Introduction to Android and Android Studio
Page 46: Introduction to Android and Android Studio

MORE ON ANDROID STUDIO

Page 47: Introduction to Android and Android Studio
Page 48: Introduction to Android and Android Studio

ADB

Page 49: Introduction to Android and Android Studio

• Connect to an Android device or emulator• Read logcat• Install, reinstall or uninstall apps• Send/retrieve files to/from device storage• Forward ports• Record screen or take screenshots• Reboot your phone into boot loader or recovery

mode• Take backups or restore them• Execute shell commands

Page 50: Introduction to Android and Android Studio

DEVICE MONITOR

Page 51: Introduction to Android and Android Studio
Page 52: Introduction to Android and Android Studio

LOGCAT

Page 53: Introduction to Android and Android Studio
Page 54: Introduction to Android and Android Studio

SDK MANAGER

Page 55: Introduction to Android and Android Studio
Page 56: Introduction to Android and Android Studio

WORKFLOW

Page 57: Introduction to Android and Android Studio
Page 58: Introduction to Android and Android Studio

THERE’S STILL A LOT TO COVER…NDK, Support Library, Google services APIs, Monetization, etc.

Page 59: Introduction to Android and Android Studio

THANK YOU

Page 60: Introduction to Android and Android Studio

PLEASE FOLLOW US ON SOCIAL MEDIA CHANNELS FOR INFORMATION ON UPCOMING

EVENTS, TALKS AND MORE

@gdgoxfordfb.com/gdgoxford

plus.google.com/+GdgoxfordUkGoogleDevelopers/