Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Wear App Development

KMKLabs
February 03, 2016

Android Wear App Development

Topik ini menjelaskan tentang bagaimana membuat aplikasi untuk android wear serta komponen - komponen UI yang dibutuhkan untuk membuat Android Wear.

KMKLabs

February 03, 2016
Tweet

More Decks by KMKLabs

Other Decks in Technology

Transcript

  1. Supported Devices • Android phone (or tablet) running Android 4.3

    or higher that supports Bluetooth • iPhone running iOS 8.2 or higher (with limited support)
  2. Debugging There are 2 ways to debug the device: •

    Using USB connection Easier, but supported to only devices with USB connection • Debugging over Bluetooth Need a bit work to do, but supported to many devices
  3. Debugging • Enable Developer options (tap build number 7 times)

    • Go to Developer options and enable ADB debugging • When properly connected, allow the debugging when prompted
  4. Debugging (Over Bluetooth) • Enable ADB debugging (same as previous)

    • Go to Developer options and enable Debug over Bluetooth option • Connect paired phone • Open terminal, and run command (This must be done every time device reconnected) Note: the port can be any available port, doesn’t have to be 4444
  5. Debugging (Emulator) • Start wear emulator and make sure it

    is ready to debug (run adb devices) • Forward the AVD communication port by running command: (This command must be run every time handheld connected) • Start Android Wear app on handheld device • Select pair to new device and choose option connect to emulator
  6. Wearable App Support access to standard Android APIs, except for:

    • android.webkit • android.print • android.app.backup • android.appwidget • android.hardware.usb
  7. Wearable App Minimum SDK requirement: • SDK tools version 23.0.0

    or higher • Android 4.4W.2 (API 20) or higher
  8. Wearable App There are 2 modes available: • Interactive Full

    color, with animation and responsive to input • Ambient Grayscale and not responsive to input (Only supported on device running Android 5.1 or higher)
  9. Wearable App (UI) • BoxInsetLayout • ActionPage • CircledImageView •

    CrossFadeDrawable • GridViewPager • WearableListView • WatchViewStub • CardFragment • etc
  10. Wearable App (Ambient Mode) • Update SDK to include Android

    5.1 (API 22) or higher • Set targetSdkVersion to 22 or higher • Set minSdkVersion to 20 or higher (for backward-compatibility) • Add support wearable library dependency • Add uses-library com.google.android.wearable • Add WAKE_LOCK permission • Create an activity that extends WearableActivity • Call setAmbientEnabled() in the onCreate() method
  11. Wearable App (Ambient Mode) There are 3 method to handle

    ambient mode: • onEnterAmbient Called when an activity is entering ambient mode • onExitAmbient Called when an activity should exit ambient mode • onUpdateAmbient Called when the system is updating the display for ambient mode
  12. Data Layer API • Provides communication channel for handheld and

    wearable apps • Need to add google play service dependency to handheld and wearable apps • Application ID and version number for both apps (handheld and wear) must be same in order to work
  13. Data Layer API • Data Items Provides data storage with

    automatic syncing between handheld and wearable • Messages API Provides API for sending message between handheld and wearable • Asset Used for sending binary blobs of data (attached to Data Items)
  14. Data Layer API • WearableListenerService Service that is used for

    listening data layer event • DataListener Used for listening data layer event when activity in foreground • Channel API for transferring large data items
  15. Data Layer API • Channel ◦ Transfer large data file

    without automatic synchronization provided when using Asset with Data Items. Unlike Data API, Channel API doesn’t create copy in local device before synchronizing ◦ Handle large file sending better than Messages API ◦ Transfer data from remote node (streamed data from network or voice from microphone)
  16. Publish • Wearable app must be packaged inside handheld app

    • Wearable app automatically pushed to Wear device when the paired handheld install the handheld app • Doesn’t work with debug key • Both app must have same application id, version number, and permission.
  17. Publish (Using Android Studio) • Declare dependency in build.gradle that

    points to wearable app module • Click Build > Generate Signed APK
  18. References • http://developer.android.com/training/building-wearables.html • http://developer.android.com/design/wear/index.html • http://www.androidauthority.com/why-everyone-should-learn-to-code-663860/ • http://www.technotalkative.com/android-wear-part-5-wearablelistview/ •

    https://github. com/teshi04/WearViewSample/blob/master/wear/src/main/java/jp/tsur/sampleapp lication/CrossfadeDrawableActivity.java • http://gmariotti.blogspot.co.id/2014/07/wear-gist4-how-to-use-simple.html • http://stackoverflow.com/questions/30018709/android-wear-wearable-channelapi- openchannel-not-opening-with-remote-node • https://www.binpress.com/tutorial/a-guide-to-the-android-wear-message-api/152