行動App開發管理實務 unit1

Post on 12-Aug-2015

118 Views

Category:

Education

2 Downloads

Preview:

Click to see full reader

Transcript

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

尹君耀 Xavier Yin

Outline

Environment

Android Studio Overview

Project Structure

The First Android App

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

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

Devices

Real Devices– With USB

Android Emulator– android avd

Genymotion– Plugin

Android Studio Overview

Interface

Android Studio Overview

Interface– Tool bar

Android Studio Overview

Interface– Tool bar

– Navigation bar

Android Studio Overview

Interface– Tool bar

– Navigation bar

– Project structure

Android Studio Overview

Interface– Tool bar

– Navigation bar

– Project structure

– Code editor

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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.

App Manifest

App Manifest

App Manifest

Dimens

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

usually referred to as dpi (dots per inch).

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

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.

The First Android App

Requirements

The First Android App

Requirements 10dp

10dp#FFEFAAE5

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

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

Sample Code and Slides

Slides– Slideshare

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

top related