tehran's 2nd android bootcamp

37
You’re Welcome to Tehran 2 nd Android Bootcamp Hi

Upload: mohsen-mirhoseini-argi

Post on 14-Feb-2017

101 views

Category:

Education


6 download

TRANSCRIPT

Page 1: Tehran's 2nd Android bootcamp

You’re Welcome toTehran 2nd

Android BootcampHi

Page 2: Tehran's 2nd Android bootcamp

Android 1st Bootcamp Overview

سمینار اولین مطالب اندروید بر مروری

Page 3: Tehran's 2nd Android bootcamp

Android Means

an·droid /ˈanˌdroid/

Noun

(in science fiction)A robot with a human appearance.

Page 4: Tehran's 2nd Android bootcamp

Android…• Is an open source platform designed for mobiles

devices under licenses (Apache/MIT)• Is based on the open Linux kernel– Portability: easy to compile on various hardware– Security: a highly secure system– Features: support for memory management, power

management, and networking• Championed by Google• Separates the hardware from the software• Core is designed to be portable to run on all sorts of

physical devices and screen size

Page 5: Tehran's 2nd Android bootcamp

Android Historyاندروید تاریخچه

Page 6: Tehran's 2nd Android bootcamp

Android Versionsاندروید نسخه‌های

Page 7: Tehran's 2nd Android bootcamp

Android Futureاندروید آینده

Page 8: Tehran's 2nd Android bootcamp

Android Next Versions 4.3? or 5?

Jelly Bean/Key Lime Pie?• next Android update

won’t be a major new release?

• ??? ?Google I/O 2013 begins on:Wednesday, May 15and ends on:Friday, May 17

Page 9: Tehran's 2nd Android bootcamp

Android Management Switch UpAndy Rubin, head of Android at Google, moved on to a new role at the company.

Sundar Pichai (Pichai Sundarajan), head of Chrome and Apps, is now in charge of Android.

2013/03/13

Page 10: Tehran's 2nd Android bootcamp

Installing the Android SDKاندروید نویسی برنامه ابزار نصب

Page 11: Tehran's 2nd Android bootcamp

Hello, Worldاندروید پروژه اولین ایجاد

Page 12: Tehran's 2nd Android bootcamp

Android Project Partsاندروید پروژه یک بخشهای

Page 13: Tehran's 2nd Android bootcamp

The Emulatorاندروید مجازی ماشین

Page 14: Tehran's 2nd Android bootcamp

Emulator with -Android 4.2.2 AVD

Page 15: Tehran's 2nd Android bootcamp

Android Websites

• www.android.com• developer.android.com• play.google.com• www.stackoverflow.com• www.openhandsetalliance.com

Page 16: Tehran's 2nd Android bootcamp
Page 17: Tehran's 2nd Android bootcamp

Activities

• usually a single screen that the user sees• the most visible part of your application• An application typically has multiple activities• user flips back and forth among them• like a website consists of multiple pages• “home page” -> Android app has a “main”• one that is shown first

Page 18: Tehran's 2nd Android bootcamp

Activity Life Cycle

• Launching an activity can be quite expensive– creating a new Linux

process– allocating memory for all

the UI objects– inflating all the objects

from XML layouts– setting up the whole

screen

Page 19: Tehran's 2nd Android bootcamp
Page 20: Tehran's 2nd Android bootcamp

Intents

• are messages that are sent among the major building blocks

• are asynchronous• Intents:– trigger an activity to start up– tell a service to start or stop– or are simply broadcasts

• Could be explicit / implicit

Page 21: Tehran's 2nd Android bootcamp

Intents

Page 22: Tehran's 2nd Android bootcamp
Page 23: Tehran's 2nd Android bootcamp

Android User Interfaceاندروید کاربری رابط

Page 24: Tehran's 2nd Android bootcamp

Creating a User Interface• Two Ways to Create a User Interface:

– Declarative User Interface• involves using XML• similar to creating a web page using HTML• write tags and specify elements to appear• WYSIWYG tool (what-you-see-is-what-you-get)

– Programmatic User Interface• involves writing Java code (like Java AWT or Java Swing)• For example to have a Button:

– you have to declare the button variable– create an instance of it– add it to a container– set any button properties (such as color, text, text size, background,…)

Page 25: Tehran's 2nd Android bootcamp

The best practice is to use both

• The Best of Both Worlds• use a declarative XML for static user interface• then switch to Java to define what goes on

• For example:– use XML to declare what the “button” looks like

and Java to specify what it does

Page 26: Tehran's 2nd Android bootcamp
Page 27: Tehran's 2nd Android bootcamp

Views and Layouts

• Everything you see (such as button, label, or text box) is a view = Widgets/Views

• Layouts organize views• Layout can contain other children• layout is responsible for allocating space for

each child• children can be layouts themselves

Page 28: Tehran's 2nd Android bootcamp

Views and Layouts

Page 29: Tehran's 2nd Android bootcamp

LinearLayout

• simplest and most common layouts• lays out its children next to each other, either

horizontally or vertically• order of the children matters• LinearLayout asks its children how much space

they need• allocates the desired space to each child in the

order they are added

Page 30: Tehran's 2nd Android bootcamp

TableLayout• lays out its children in a table (like <table> tag)• consists of only other TableRow widgets• TableRow represents a row in a table and can

contain other UI widgets (like <tr> tag)• TableRow sort of like horizontal LinearLayout• columns are determined dynamically based on the

number of views• important property is stretch_columns– Include which column of the table to stretch / *

Page 31: Tehran's 2nd Android bootcamp

FrameLayout

• places its children on top of each other• the latest child is covering the previous• like a deck of cards• layout policy is useful for tabs• also used as a placeholder for other widgets

that will be added programmatically

Page 32: Tehran's 2nd Android bootcamp

RelativeLayout

• lays out its children relative to each other• it is very powerful• can minimize the total number of widgets• each of its child views requires to have an ID

Page 33: Tehran's 2nd Android bootcamp
Page 34: Tehran's 2nd Android bootcamp

Images

• goes to a resource folder called drawable:– /res/drawable-hdpi for high-density screens– /res/drawable-mdpi for medium-density screens– /res/drawable-ldpi for low-density screens

• /res/drawable independent of screen density• PNG is preferred to the GIF and doesn’t require

any patent licenses• In Java have a reference to R.drawable.______

Page 35: Tehran's 2nd Android bootcamp

Colors

• you can express color as RGB or ARGB• In hexadecimal system between 00 and FF• values could be AARRGGBB• also a shorter version of ARGB– #3A9F = #33AA99FF

• res/colors.xml

Page 36: Tehran's 2nd Android bootcamp

Alternative Resources• Using qualifiers, you can create alternative resources for:

– languages and regions, screen sizes and orientations, device input modes (touch screen, stylus), keyboard or no keyboard

• user is in Quebec and her device is configured to favor the French language– res/values-fr-rCA/strings.xml

• fr: France• rCa: Canada

• user is in Iran and her device is configured• to favor the Farsi language

– res/values-fa/strings.xml• fa: Farsi

Page 37: Tehran's 2nd Android bootcamp

Hierarchy Viewer

• useful tool that ships with the Android SDK called Hierarchy Viewer

• in your SDK/tools directory• allows you to attach to any Android device• all the widgets currently loaded in memory• their relationships to each other, and all their

properties