Mobile
     Software
  Engineering
L03 – Android

               Mohammad Shaker
        FIT of Damascus - AI dept.
   MohammadShakerGtr@gmail.com
          Mobile SE – August 2012
Android Developer
http://developer.android.com
SDK Download
http://developer.android.com/sdk/index.html
eclipse Android plugin
instructions @ http://developer.android.com/tools/sdk/eclipse-adt.html
Crazy Stuff
http://www.xda-developers.com/
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
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.
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.
First sight
First sight
Activity Life Cycle
http://developer.android.com/reference/android/app/Activity.html
Basic Components
Layouts
•   FrameLayout
•   Gallery
•   GridView
•   LinearLayout
•   ListView
•   RelativeLayout
•   ScrollView
•   Spinner
•   SurfaceView
•   TabHost
•   TableLayout
•   ViewFlipper
•   ViewSwitcher
Create Your First
 Android App
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
Running on the fly
Emulator
Run on a Real Device
http://developer.android.com/training/basics/firstapp/running-app.html
Setting Real Android Device
         Connection
http://developer.android.com/tools/extras/oem-usb.html#Drivers
Capturing Screen from Real Device
http://www.butterscotch.com/tutorial/How-To-Display-Your-Android-Screen-On-Your-Desktop
Live from ARC :P
Live from ARC :P
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>
XML Namespace - xmlns
   http://www.w3.org/TR/REC-xml-names/
Adding your first button




             Designer VS Code
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" />
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" />
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" />
Events
• MainActivity.java file
public void toggleMessageOnClick(View view) {
    // Do something in response to button
    TextView textView =
            (TextView)findViewById(R.id.textView1);
    textView.setText("Bonjour Monde!");
}
Congrats! Run and see!
Project (HelloWorld) is attached in case u wanna look at it

Mobile Software Engineering Crash Course - C03 Android

  • 1.
    Mobile Software Engineering L03 – Android Mohammad Shaker FIT of Damascus - AI dept. MohammadShakerGtr@gmail.com Mobile SE – August 2012
  • 2.
  • 3.
  • 4.
    eclipse Android plugin instructions@ http://developer.android.com/tools/sdk/eclipse-adt.html
  • 5.
  • 6.
    Constraints • No supportfor 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
  • 9.
    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.
  • 10.
    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.
  • 11.
  • 12.
  • 13.
  • 15.
  • 16.
    Layouts • FrameLayout • Gallery • GridView • LinearLayout • ListView • RelativeLayout • ScrollView • Spinner • SurfaceView • TabHost • TableLayout • ViewFlipper • ViewSwitcher
  • 21.
    Create Your First Android App
  • 22.
    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
  • 23.
  • 24.
  • 25.
    Run on aReal Device http://developer.android.com/training/basics/firstapp/running-app.html
  • 26.
    Setting Real AndroidDevice Connection http://developer.android.com/tools/extras/oem-usb.html#Drivers
  • 27.
    Capturing Screen fromReal Device http://www.butterscotch.com/tutorial/How-To-Display-Your-Android-Screen-On-Your-Desktop
  • 28.
  • 29.
  • 30.
    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>
  • 31.
    XML Namespace -xmlns http://www.w3.org/TR/REC-xml-names/
  • 32.
    Adding your firstbutton Designer VS Code
  • 33.
    Adding your firstbutton <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" />
  • 34.
    Adding your firstbutton • 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" />
  • 35.
    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" />
  • 36.
    Events • MainActivity.java file publicvoid toggleMessageOnClick(View view) { // Do something in response to button TextView textView = (TextView)findViewById(R.id.textView1); textView.setText("Bonjour Monde!"); }
  • 37.
    Congrats! Run andsee! Project (HelloWorld) is attached in case u wanna look at it