Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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 do...
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/ind...
Hello World: Installing SDK3. Install Android ADT Plugin for Eclipse  http://developer.android.com/sdk/eclipse-adt.html#in...
Hello World: Installing SDK4. Setup ADT Plugin a. Ecplise > Preferences > Android b. Point to your Android ADK Location (f...
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 ...
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...
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 ... >     ...
Fundamentals: Service•   Service or Thread ?•   Service runs in the background, even when user is not    interacting with ...
Fundamentals: ContentProvider• A way to share data across applications,   including apps such as phonebook,   calendar, et...
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...
User Interfaces: Codepackage com.example.helloandroid;import android.app.Activity;import android.os.Bundle;import android....
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 l...
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 • Extr...
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/...
Bluetooth: Connect to Android1. Connect from Bluetooth modem to Arduino •   VCC to +3.3V •   GND to GND •   TX-0 to PIN-2 ...
Bluetooth: Connect to Android
Bluetooth: Connect to Android 2. Import NewSoftSerial library to Arduino   •   Provides an interrupt architecture (vs Soft...
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 targ...
Bluetooth: Connect to Android5. To send a message •   Pair up: Settings > Wireless & network > Bluetooth > Select FireFly-...
Bluetooth: Connect to Android6. Change baud rate to 57,000 •   Refer to http://www.instructables.com/id/Change-BAUD-rate-o...
USB Host ShieldA guide from circuitathome
Android Workshop
Android Workshop
Android Workshop
Upcoming SlideShare
Loading in …5
×

Android Workshop

10,913 views

Published on

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.

Published in: Technology
  • Be the first to comment

Android Workshop

  1. 1. Android Workshop Android application development & connectivity to Arduino
  2. 2. About Myself
  3. 3. My Hobby Projects just2us.com
  4. 4. My Full Time developer.hoiio.com
  5. 5. Hoiio API
  6. 6. Hoiio APIMr Brown Podcast Over The Phone!! Call 6602 8104
  7. 7. Android Apps: txeet
  8. 8. Android Apps: txeet ~250,000 downloads
  9. 9. Android Apps: SG 4D
  10. 10. Android Apps: Hoiio Phone
  11. 11. Android Apps: Hoiio Chat
  12. 12. Workshop Topics1. Introduction to Android2. Hello World!3. Application Fundamentals4. User Interfaces5. Bluetooth
  13. 13. 1. Introduction to Android
  14. 14. Introduction• Linux Kernel• Application Framework• Dalvik Virtual Machine• App distributed as an .apk• Ten billion apps downloaded
  15. 15. Introduction: Development Process
  16. 16. Introduction: Resources• http://developer.android.com• http://stackoverflow.com/• http://www.google.com/
  17. 17. 2. Hello World
  18. 18. 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
  19. 19. 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
  20. 20. 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
  21. 21. Hello World: Create• File > New > Android Project
  22. 22. Hello World: Run• Run > Run as > Android Application• If running on actual device, do this first: Settings > Applications > Development and turn on USB debugging
  23. 23. Now you see “Hello World”, let’s look at the code..
  24. 24. 3. Application Fundamentals
  25. 25. Fundamentals• 4 components 1. Activity 2. Service 3. ContentProvider 4. BroadcastReceiver
  26. 26. 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);
  27. 27. Fundamentals: Activity• Activities form a stack• Functions to handle events: onCreate, onResume, onPause, etc
  28. 28. Fundamentals: Activity• Activity must be declared in AndroidManifest.xml <manifest ... >   <application ... >       <activity android:name=".ExampleActivity" />       ...   </application ... >   ... </manifest >
  29. 29. 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.
  30. 30. 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)
  31. 31. Fundamentals: ContentProvider Let’s look at a sample code
  32. 32. 4. User Interfaces
  33. 33. User Interfaces• 2 ways to construct UI 1. XML 2. Code
  34. 34. 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); }
  35. 35. 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);   }}
  36. 36. UI LayoutsLinearLayout
  37. 37. UI LayoutsTableLayout
  38. 38. UI LayoutsRelativeLayout
  39. 39. View HierarchyViewGroup: Layout or container viewView: Android UI component, view or widgets
  40. 40. View Hierarchy
  41. 41. UI Views• Look at “Hello View” tutorial • http://developer.android.com/resources/tutorials/views/index.html• Also look at “Api Demo” sample code
  42. 42. User Interfaces• Common UI Patterns http://www.androidpatterns.com/
  43. 43. Change view on a set of data
  44. 44. Select multiple items
  45. 45. dashboard
  46. 46. 5. Bluetooth
  47. 47. 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
  48. 48. Bluetooth: The Pins• Pins from left to right • GND • CTS-1 • VCC • TX-0 • RX-1 • RTS-0
  49. 49. 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
  50. 50. 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
  51. 51. Bluetooth: Connect to Android
  52. 52. 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 >
  53. 53. Bluetooth: Connect to Android3. Upload sketch to Arduino • /Sample Code/bluetooth/bluetooth.pde
  54. 54. 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
  55. 55. 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.
  56. 56. 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..
  57. 57. USB Host ShieldA guide from circuitathome

×