• Save
Android Workshop
Upcoming SlideShare
Loading in...5
×
 

Android Workshop

on

  • 10,803 views

Android workshop to prepare for 48hacks (http://www.ntuventures.com/events/48hacks/index.html), organized by NTU Venture....

Android workshop to prepare for 48hacks (http://www.ntuventures.com/events/48hacks/index.html), organized by NTU Venture.

Covers basic Android application programming, and connectivity to Arduino board via Bluetooth.

Statistics

Views

Total Views
10,803
Views on SlideShare
2,729
Embed Views
8,074

Actions

Likes
2
Downloads
0
Comments
0

7 Embeds 8,074

http://www.just2me.com 8025
http://translate.googleusercontent.com 27
http://1819089270316006574_6da89cb24366f80f63b280c0805be32aff367e82.blogspot.com 17
http://live.swiftype.com 2
http://feeds.feedburner.com 1
http://translate.google.com.pe 1
http://webcache.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • http://developer.android.com/guide/basics/what-is-android.html\n\nhttp://kschang.hubpages.com/slide/Cupcake-Donut-Eclair-Froyo-Gingerbread-Honeycomb-Android-OS-Version-Codenames-and-Why/4609964\n
  • http://www.android.com/about\n
  • Android != Linux\nUsed Linux security, mem mgmt, threading, etc\nEach app, 1 VM instance\nOptimized for mobile\nAndroid Package. A zip. Like Jar.\n\n
  • http://developer.android.com/guide/developing/index.html\n
  • http://developer.android.com/guide/basics/what-is-android.html\n
  • \n
  • \n
  • \n
  • \n
  • http://developer.android.com/resources/tutorials/hello-world.html\n
  • http://developer.android.com/resources/tutorials/hello-world.html\n
  • http://developer.android.com/resources/tutorials/hello-world.html\n
  • \n
  • http://developer.android.com/guide/topics/fundamentals.html\n
  • http://developer.android.com/guide/topics/fundamentals.html\nActivity - A single screen (UI)\nService - background activity eg. play music globally\nContentProvider - Even share data across apps. SQLite. eg. contacts. ContentResolver\nBroadcastReceiver - Responds to system wide broadcast announcements. Usually from the system eg. Send Message, Picture captured\n
  • \n
  • \n
  • Activity lifecycle\n
  • \n
  • http://developer.android.com/guide/topics/fundamentals/services.html\n
  • http://developer.android.com/guide/topics/providers/content-providers.html\nhttp://developer.android.com/reference/android/provider/package-summary.html\n
  • http://developer.android.com/guide/topics/providers/content-providers.html\nhttp://developer.android.com/reference/android/provider/package-summary.html\n
  • http://developer.android.com/guide/topics/fundamentals.html\n
  • \n
  • \n
  • \n
  • http://developer.android.com/guide/topics/ui/layout-objects.html \n
  • http://developer.android.com/guide/topics/ui/layout-objects.html \n
  • http://developer.android.com/guide/topics/ui/layout-objects.html \n
  • \n
  • \n
  • http://developer.android.com/reference/android/widget/package-summary.html\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • http://www.arduino.cc/en/Hacking/Libraries\n
  • \n
  • \n
  • \n
  • http://www.sparkfun.com/products/9716\n
  • http://www.circuitsathome.com/mcu/exchanging-data-between-usb-devices-and-android-phone-using-arduino-and-usb-host-shield\n\nhttps://github.com/felis/USB_Host_Shield_2.0\n\n

Android Workshop Android Workshop Presentation Transcript

  • Android Workshop Android application development & connectivity to Arduino
  • About Myself
  • My Hobby Projects just2us.com
  • My Full Time developer.hoiio.com
  • Hoiio API
  • Hoiio APIMr Brown Podcast Over The Phone!! Call 6602 8104
  • Android Apps: txeet
  • Android Apps: txeet ~250,000 downloads
  • Android Apps: SG 4D
  • Android Apps: Hoiio Phone
  • Android Apps: Hoiio Chat
  • Workshop Topics1. Introduction to Android2. Hello World!3. Application Fundamentals4. User Interfaces5. Bluetooth
  • 1. Introduction to Android
  • Introduction• Linux Kernel• Application Framework• Dalvik Virtual Machine• App distributed as an .apk• Ten billion apps downloaded
  • Introduction: Development Process
  • Introduction: Resources• http://developer.android.com• http://stackoverflow.com/• http://www.google.com/
  • 2. Hello World
  • Hello World: Installing SDK1. Install Eclipse - the IDE http://www.eclipse.org/downloads/packages/eclipse-classic-371/indigosr12. Install Android SDK http://developer.android.com/sdk/index.html Guide from http://developer.android.com/sdk/installing.html
  • Hello World: Installing SDK3. Install Android ADT Plugin for Eclipse http://developer.android.com/sdk/eclipse-adt.html#installing a. Eclipse > Help > Install new software b. Add repository https://dl-ssl.google.com/android/eclipse/ c. Select “Developer Tools” d. Next, next, next and finish! Guide from http://developer.android.com/sdk/installing.html
  • Hello World: Installing SDK4. Setup ADT Plugin a. Ecplise > Preferences > Android b. Point to your Android ADK Location (from step 2) Guide from http://developer.android.com/sdk/installing.html
  • Hello World: Create• File > New > Android Project
  • Hello World: Run• Run > Run as > Android Application• If running on actual device, do this first: Settings > Applications > Development and turn on USB debugging
  • Now you see “Hello World”, let’s look at the code..
  • 3. Application Fundamentals
  • Fundamentals• 4 components 1. Activity 2. Service 3. ContentProvider 4. BroadcastReceiver
  • Fundamentals: Activity• Launch an Activity by calling startActivity(intent) Launch a known Activity Intent intent = new Intent(this, SignInActivity.class); startActivity(intent); Initiate a system launch Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, recipientArray); startActivity(intent);
  • Fundamentals: Activity• Activities form a stack• Functions to handle events: onCreate, onResume, onPause, etc
  • Fundamentals: Activity• Activity must be declared in AndroidManifest.xml <manifest ... >   <application ... >       <activity android:name=".ExampleActivity" />       ...   </application ... >   ... </manifest >
  • Fundamentals: Service• Service or Thread ?• Service runs in the background, even when user is not interacting with your app.• To start, call startService()• Similar to Activity, has its lifecycle and various event callbacks.
  • Fundamentals: ContentProvider• A way to share data across applications, including apps such as phonebook, calendar, etc.• In other words, you can access the phonebook using a ContentProvider• Have query, insert, delete methods (SQLite)ContentResolver cr = getContentResolver();cr.query(“content://android.provider.Contacts.Phones.CONTACT_URI”, projection, selection, selectionArg, sortOrder)
  • Fundamentals: ContentProvider Let’s look at a sample code
  • 4. User Interfaces
  • User Interfaces• 2 ways to construct UI 1. XML 2. Code
  • User Interfaces: XML /res/layout/main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /></LinearLayout> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }
  • User Interfaces: Codepackage com.example.helloandroid;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloAndroid extends Activity {   /** Called when the activity is first created. */   @Override   public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       TextView tv = new TextView(this);       tv.setText("Hello, Android");       setContentView(tv);   }}
  • UI LayoutsLinearLayout
  • UI LayoutsTableLayout
  • UI LayoutsRelativeLayout
  • View HierarchyViewGroup: Layout or container viewView: Android UI component, view or widgets
  • View Hierarchy
  • UI Views• Look at “Hello View” tutorial • http://developer.android.com/resources/tutorials/views/index.html• Also look at “Api Demo” sample code
  • User Interfaces• Common UI Patterns http://www.androidpatterns.com/
  • Change view on a set of data
  • Select multiple items
  • dashboard
  • 5. Bluetooth
  • Bluetooth• Bluetooth Modem, aka BlueSMiRF Gold, aka Firefly• http://www.sparkfun.com/products/582• Specifications • Extremely small • Operating Voltage: 3.3V-6V • Serial communications: 2400-115200bps
  • Bluetooth: The Pins• Pins from left to right • GND • CTS-1 • VCC • TX-0 • RX-1 • RTS-0
  • Bluetooth: Connect to Android• A guide from instructables.com http://www.instructables.com/id/Android-talks-to-Arduino/?ALLSTEPS• !!! NOTE: Arduino version 1.0 does not work with the libraries. Download version 0023 instead http://arduino.cc/en/Main/Software
  • Bluetooth: Connect to Android1. Connect from Bluetooth modem to Arduino • VCC to +3.3V • GND to GND • TX-0 to PIN-2 (RX) • RX-1 to PIN-3 (TX) If works, you will see a red LED blinking
  • Bluetooth: Connect to Android
  • Bluetooth: Connect to Android 2. Import NewSoftSerial library to Arduino • Provides an interrupt architecture (vs SoftwareSerial) • Copy /Library/NewSoftSerial to: • Mac: ~/Documents/Arduino/libraries/ • Windows: My DocumentsArduinolibraries • Instructions on how to use at http://arduiniana.org/libraries/ newsoftserial/You will see NewSoftSerial in Sketch > Import Library >
  • Bluetooth: Connect to Android3. Upload sketch to Arduino • /Sample Code/bluetooth/bluetooth.pde
  • Bluetooth: Connect to Android4. Open BluetoothChat, an Android sample app • File > New > Android Project • Select target Android 2.3.3 • Create project from existing sample > BluetoothChat > Finish • In BluetoothChatService, change the UUID to "00001101-0000-1000-8000-00805F9B34FB" • Build and deploy to phone
  • Bluetooth: Connect to Android5. To send a message • Pair up: Settings > Wireless & network > Bluetooth > Select FireFly-xxxx. Password is 1234. • Connect: Open BluetoothChat app. Press Menu > Connect > FireFly-xxxx • When connected, Bluetooth modem will have green light • Type a message and send. If success, PIN 13 will light up for 5 sec.
  • Bluetooth: Connect to Android6. Change baud rate to 57,000 • Refer to http://www.instructables.com/id/Change-BAUD-rate-on-BlueSMiRF- Gold/ • Need FTDI Basic chip..
  • USB Host ShieldA guide from circuitathome