tehran's 2nd android bootcamp

Post on 14-Feb-2017

100 Views

Category:

Education

6 Downloads

Preview:

Click to see full reader

TRANSCRIPT

You’re Welcome toTehran 2nd

Android BootcampHi

Android 1st Bootcamp Overview

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

Android Means

an·droid /ˈanˌdroid/

Noun

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

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

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

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

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

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

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

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

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

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

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

Emulator with -Android 4.2.2 AVD

Android Websites

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

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

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

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

Intents

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

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,…)

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

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

Views and Layouts

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

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 / *

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

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

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.______

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

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

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

top related