行動app開發管理實務 unit1

36
行行 APP 行行行行行行 Android Studio Overview and Practice 行行行 Xavier Yin

Upload: xavier-yin-

Post on 12-Aug-2015

120 views

Category:

Education


2 download

TRANSCRIPT

Page 1: 行動App開發管理實務 unit1

行動 APP 開發管理實務Android Studio Overview and Practice

尹君耀 Xavier Yin

Page 2: 行動App開發管理實務 unit1

Outline

Environment

Android Studio Overview

Project Structure

The First Android App

Page 3: 行動App開發管理實務 unit1

Environment

JDK– Download JDK (or from Oracle)– Installation and Environment Variable Settings

JAVA_HOME PATH Installation result on cmd

Android SDK and Studio– Download Android SDK and Studio (or from Android Developer)– Installation

Launch the .exe file you just downloaded Follow the setup wizard

Page 4: 行動App開發管理實務 unit1

Android SDK

Platform-tools folder– Adb(Android Debug Bridge) instructions

devices: Prints a list of all attached emulator/device instances. logcat: Prints log data to the screen. push: Copies a specified file from an emulator/device instance to your

development computer pull: Copies a specified file from your development computer to an

emulator/device instance.

Tools folder Android– avd: Launch the AVD Manager– sdk: Launch the Android SDK Manager

Page 5: 行動App開發管理實務 unit1

Devices

Real Devices– With USB

Android Emulator– android avd

Genymotion– Plugin

Page 6: 行動App開發管理實務 unit1

Android Studio Overview

Interface

Page 7: 行動App開發管理實務 unit1

Android Studio Overview

Interface– Tool bar

Page 8: 行動App開發管理實務 unit1

Android Studio Overview

Interface– Tool bar

– Navigation bar

Page 9: 行動App開發管理實務 unit1

Android Studio Overview

Interface– Tool bar

– Navigation bar

– Project structure

Page 10: 行動App開發管理實務 unit1

Android Studio Overview

Interface– Tool bar

– Navigation bar

– Project structure

– Code editor

Page 11: 行動App開發管理實務 unit1

Android Studio Overview

Features– Flexible Gradle-based build system

– Build variants and multiple apk file generation

– Code templates to help you build common app features

– Rich layout editor with support for drag and drop theme editing

– lint tools to catch performance, usability, version compatibility, and other problems

– And much more

Page 12: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 13: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 14: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 15: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 16: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 17: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 18: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 19: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 20: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 21: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 22: 行動App開發管理實務 unit1

Android Studio Overview

Details– Auto Complete– Build Variants– Productivity Guild– Multi Devices Debug– Layout Preview for Multi

Devices– Plugins– Code Template– Layout Tools Attributes– Resource Preview– And much more

Page 23: 行動App開發管理實務 unit1

Project Structure

/app– /src

/main/java– /your_package_name (ex: /com/tku/android -> com.tku.android)

Java files– AndroidManifest.xml

/androidTest(For Android Test)– /java/your_package_name

Test cases /res– /drawable– /layout– /values

colors.xml, dimens.xml, strings.xml, styles.xml…etc. build.gradle

Page 24: 行動App開發管理實務 unit1

Resources

Drawable– A drawable resource is a general concept for a graphic that

can be drawn to the scree.

values– strings: A string resource provides text strings for your application

with optional text styling and formatting.

– colors: A ColorStateList is an object you can define in XML that you can apply as a color, but will actually change colors, depending on the state of the View object to which it is applied.

– styles: A style resource defines the format and look for a UI.

– dimens: A dimension is specified with a number followed by a unit of measure.

Page 25: 行動App開發管理實務 unit1

App Manifest

Manifest file– The manifest file presents essential information about your app

to the Android system, information the system must have before it can run any of the app's code.

Permission– A basic Android application has no permissions associated with it

by default, meaning it cannot do anything that would adversely impact the user experience or any data on the device.

– To make use of protected features of the device, you must include in your AndroidManifest.xml one or more <uses-permission> tags declaring the permissions that your application needs.

Page 26: 行動App開發管理實務 unit1

App Manifest

Page 27: 行動App開發管理實務 unit1

App Manifest

Page 28: 行動App開發管理實務 unit1

App Manifest

Page 29: 行動App開發管理實務 unit1

Dimens

DPI (Dots Per Inch)– The quantity of pixels within a physical area of the screen;

usually referred to as dpi (dots per inch).

Page 30: 行動App開發管理實務 unit1

Dimens

PX, DPI and DP(DIP)– Icon size = 160px

MDPI -> 160px/160dpi = 1 inch XHDPI -> 160px/320dpi = 0.5 inch

– Icon size = 160dp -> px = dp * (dpi / 160 ) MDPI -> px = 160 * ( 160dpi / 160dpi ) , px = 160 XHDPI -> px = 160 * ( 320dpi / 160dpi) , px = 320

Page 31: 行動App開發管理實務 unit1

Dimens

Suggestions– Because it's important that you design and implement your

layouts for multiple densities, the guidelines below and throught the documentation refer to layout dimensions with dp measurements instead of pixels.

– Similarly, you should prefer the sp (scale-independent pixel) to define text sizes. The sp scale factor depends on a user setting and the system scales the size the same as it does for dp.

Page 32: 行動App開發管理實務 unit1

The First Android App

Requirements

Page 33: 行動App開發管理實務 unit1

The First Android App

Requirements 10dp

10dp#FFEFAAE5

Page 34: 行動App開發管理實務 unit1

The First Android App

Create a new project– Empty project

Define resources that you need– Colors.xml, dimens.xml, strings.xml, styles.xml, drawable

Prepare Layout files– Add Android Resource Directory named layout within res folder– Add a layout.xml

LinearLayout

Page 35: 行動App開發管理實務 unit1

The First Android App

Bind the above files with your java files– Activity

SetContentView() FindViewById()

Define App Manifest file– Intent– Intent-filter

Launch your App in a device

Page 36: 行動App開發管理實務 unit1

Sample Code and Slides

Slides– Slideshare

Sample Code– https://github.com/xavier0507/TKUSampleCode.git