Mobile Software Engineering Crash Course - C03 Android

37
Mohammad Shaker FIT of Damascus - AI dept. [email protected] Mobile SE – August 2012 Mobile Software Engineering L03 – Android

description

 

Transcript of Mobile Software Engineering Crash Course - C03 Android

Page 1: Mobile Software Engineering Crash Course - C03 Android

Mohammad Shaker

FIT of Damascus - AI dept.

[email protected]

Mobile SE –August 2012

Mobile

Software

Engineering

L03 –Android

Page 2: Mobile Software Engineering Crash Course - C03 Android

Android Developerhttp://developer.android.com

Page 3: Mobile Software Engineering Crash Course - C03 Android

SDK Downloadhttp://developer.android.com/sdk/index.html

Page 4: Mobile Software Engineering Crash Course - C03 Android

eclipse Android plugininstructions @ http://developer.android.com/tools/sdk/eclipse-adt.html

Page 5: Mobile Software Engineering Crash Course - C03 Android

Crazy Stuffhttp://www.xda-developers.com/

Page 6: Mobile Software Engineering Crash Course - C03 Android

Constraints

• No support for placing or receiving actual phone calls.

• You can simulate phone calls (placed and received) through the emulator console, however.

• No support for USB connections

• No support for camera/video capture (input).

• No support for device-attached headphones

• No support for determining connected state

• No support for determining battery charge level and AC

charging state

• No support for determining SD card insert/eject

• No support for Bluetooth

Page 7: Mobile Software Engineering Crash Course - C03 Android
Page 8: Mobile Software Engineering Crash Course - C03 Android
Page 9: Mobile Software Engineering Crash Course - C03 Android

Tools

• android - Android SDK manager. Create/delete/view Android Virtual Devices and update the SDK with new platforms/add-ons.

• ddms - Dalvik Debug Monitor Server. Screen caps, thread/heap info, process/state info, ..

• emulator - The application responsible for opening AVDs instances.

• sqlite3 - manage SQLite databases.

Page 10: Mobile Software Engineering Crash Course - C03 Android

SDK – Cont.

• # adb - Android Debug Bridge. A

client/server program that manages

the state of an emulated device.

• # aapt - Android Asset Packaging Tool.

• # dx - The converter; converts .class

files to Android bytecode.

Page 11: Mobile Software Engineering Crash Course - C03 Android

First sight

Page 12: Mobile Software Engineering Crash Course - C03 Android

First sight

Page 13: Mobile Software Engineering Crash Course - C03 Android

Activity Life Cyclehttp://developer.android.com/reference/android/app/Activity.html

Page 14: Mobile Software Engineering Crash Course - C03 Android
Page 15: Mobile Software Engineering Crash Course - C03 Android

Basic Components

Page 16: Mobile Software Engineering Crash Course - C03 Android

Layouts

• FrameLayout

• Gallery

• GridView

• LinearLayout

• ListView

• RelativeLayout

• ScrollView

• Spinner

• SurfaceView

• TabHost

• TableLayout

• ViewFlipper

• ViewSwitcher

Page 17: Mobile Software Engineering Crash Course - C03 Android
Page 18: Mobile Software Engineering Crash Course - C03 Android
Page 19: Mobile Software Engineering Crash Course - C03 Android
Page 20: Mobile Software Engineering Crash Course - C03 Android
Page 21: Mobile Software Engineering Crash Course - C03 Android

Create Your First

Android App

Page 22: Mobile Software Engineering Crash Course - C03 Android

Get Started – Create Project with

eclipse

• Follow instructions @– http://developer.android.com/training/basics/firstapp/creating-

project.html

• Build SDK is the platform version against which you

will compile your app. By default, this is set to the

latest version of Android available in your SDK.

• Minimum Required SDK is the lowest version of

Android that your app supports

Page 23: Mobile Software Engineering Crash Course - C03 Android

Running on the fly

Page 24: Mobile Software Engineering Crash Course - C03 Android

Emulator

Page 25: Mobile Software Engineering Crash Course - C03 Android

Run on a Real Devicehttp://developer.android.com/training/basics/firstapp/running-app.html

Page 26: Mobile Software Engineering Crash Course - C03 Android

Setting Real Android Device

Connectionhttp://developer.android.com/tools/extras/oem-usb.html#Drivers

Page 27: Mobile Software Engineering Crash Course - C03 Android

Capturing Screen from Real Devicehttp://www.butterscotch.com/tutorial/How-To-Display-Your-Android-Screen-On-Your-Desktop

Page 28: Mobile Software Engineering Crash Course - C03 Android

Live from ARC :P

Page 29: Mobile Software Engineering Crash Course - C03 Android

Live from ARC :P

Page 30: Mobile Software Engineering Crash Course - C03 Android

activity_main.xml<RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

android:text="@string/hello_world"

tools:context=".MainActivity" />

</RelativeLayout>

Page 31: Mobile Software Engineering Crash Course - C03 Android

XML Namespace - xmlnshttp://www.w3.org/TR/REC-xml-names/

Page 32: Mobile Software Engineering Crash Course - C03 Android

Adding your first button

Designer VS Code

Page 33: Mobile Software Engineering Crash Course - C03 Android

Adding your first button

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/textView1"

android:layout_centerHorizontal="true"

android:layout_marginBottom="18dp"

android:text=“Button" />

Page 34: Mobile Software Engineering Crash Course - C03 Android

Adding your first button

• res > values > strings

• Add toggle_message to strings

• And in the activity_main.xml file<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/textView1"

android:layout_centerHorizontal="true"

android:layout_marginBottom="18dp"

android:text="@string/toggle_message" />

Page 35: Mobile Software Engineering Crash Course - C03 Android

Events

• activity_main.xml file<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_above="@+id/textView1"

android:layout_centerHorizontal="true"

android:layout_marginBottom="18dp"

android:text="@string/toggle_message“

android:onClick="toggleMessageOnClick" />

Page 36: Mobile Software Engineering Crash Course - C03 Android

Events

• MainActivity.java filepublic void toggleMessageOnClick(View view) {

// Do something in response to button

TextView textView =

(TextView)findViewById(R.id.textView1);

textView.setText("Bonjour Monde!");

}

Page 37: Mobile Software Engineering Crash Course - C03 Android

Congrats! Run and see!Project (HelloWorld) is attached in case u wanna look at it