You are on page 1of 22

移动终端的应用程序开发

Application Development on Mobile Devices


Android Development Environment

吴以凡 Yifan Wu
School of Computer Science and Technology
yfwu@hdu.edu.cn
Installation
Installation
◼ JDK

◼ Android SDK(Software Development Kit)

◼ IDE
❑ Eclipse + Android ADT

❑ Android Studio (based on IntelliJ IDEA)


◼ Google 2013 I/O Conference

* http://developer.android.com
Installation - JDK
◼ JDK includes JRE(Java Runtime Environment)、Java command line
utilities and Java library

◼ Sun JDK SE 8
❑ OS 32bit/64bit

◼ Check version
❑ java -version

* http://www.oracle.com/technetwork/java/javase/downloads/index.html
Install IDE - Android Studio
◼ IDE (Integrated Development Environment)

◼ Visit http://www.android-studio.org/ to download installer


Install IDE - Android Studio
◼ Install
Install IDE - Android Studio
◼ Choose installation location

Default location Customized location


Install IDE - Android Studio
◼ Done

Start Android Studio


Installation - Android SDK
◼ Install and update different version of SDK
❑ Open Android SDK Manager

◼ <android sdk folder>\SDK Manager.exe

◼ C:\Users\Administrator\AppData\Local\Android\sdk\SDK
Manager.exe

❑ Download specific version


◼ Android 6.0 (API 23)
Installation - Android SDK
Installation - Android SDK
◼ Install and update different version of SDK

❑ Proxy
◼ mirrors.neusoft.edu.cn

* HTTP Proxy Server should be set blank or a reliable mirror server


Android:Hello, world!
◼ Hello, world! program
❑ From Kernighan & Ritchie <The C Programme Language>

C Java
#include <stdio.h> public class Example{
int main(void) public static void main(String[] args) {
{ System.out.println("Hello, world!");
printf(“Hello, world!\n"); }
} }
Android:Hello, world!
◼ New Android Project
❑ File > New > New Project…Open New Project Dialog
Android:Hello, world!
◼ New Android Project
❑ Choose which platform and which SDK version
Android:Hello, world!
◼ New Android Project
❑ Choose default UI
Android:Hello, world!
◼ New Android Project
❑ Set Activity name, and click Finish
Android:Hello, world!
◼ Add virtual device
❑ Click AVD Mangaer
button to run
AVD Manager.exe to
crearte AVD (Android
Virtual Device)
Android:Hello, world!
◼ Add virtual device
❑ Install HAXM (Emulator Accelerator)
Android:Hello, world!
◼ Add virtual device
❑ Click run in Android Studio to run your project on the virtual
device
Project structure
◼ Folder structure
❑ libs: third-party JAR package
❑ build: auto-generated source file,
e.g., R.Java
❑ src: Java source code
❑ res: resource files
◼ drawable: pictures
◼ layout: layout files
◼ values: resource files in XML
❑ strings.xml

❑ colors.xml

❑ AndroidManifest.xml: project properties


Android:Hello, world!
◼ AndroidManifest.xml
❑ Package name
❑ Included components, e.g., Activity、Service、BroadcastReceiver、
ContentProvider
❑ Minimum support SDK version
❑ Required permissions
◼ INTERNET: visit internet
◼ READ_CONTACTS: read contacts data
◼ WRITE_CONTACTS: write contacts data
◼ RECEIVE_SMS: monitor received sms
◼ ACCESS_COARSE_LOCATION: coarse localization, e.g., WIFI
◼ ACCESS_FINE_LOCATION: fine localization, e.g., GPS
Android:Hello, world!
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=http://schemas.android.com/apk/res/android
<!—Pakcage name-->
package="com.example.cn.helloworld" >
<application
android:allowBackup="true"
<!—Application icon-->
android:icon="@mipmap/ic_launcher"
<!—Applicationlable-->
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!—Activity-->
<activity android:name=".MainActivity" >
<intent-filter>
<!—Application entry point-->
<action android:name="android.intent.action.MAIN" />
<!—Run this Activity when launch the application-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

You might also like