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

Michał Tajchert - Android Wear Deep Dive

Michał Tajchert - Android Wear Deep Dive

Avatar for Riga Dev Day

Riga Dev Day

January 30, 2015
Tweet

More Decks by Riga Dev Day

Other Decks in Programming

Transcript

  1. Notification NotificationCompat.WearableExtender wearableExtender = new NotificationCompat. WearableExtender() .setHintHideIcon(true) .setBackground(mBitmap); NotificationCompat.Builder

    notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_event) .setContentTitle(eventTitle) .setContentText(eventLocation) .setContentIntent(viewPendingIntent) .extend(wearableExtender);
  2. Standalone app • Offline mode • Custom UI • Access

    to sensors (and more) • Background work • ....
  3. Data Layer Interfaces interface DataListener { void onDataChanged(DataEventBuffer dataEvents); }

    interface MessageListener { void onMessageReceived(MessageEvent messageEvent); } interface NodeListener { void onPeerConnected(Node node); void onPeerDisconnected(Node node); }
  4. Teleport TeleportClient mTeleportClient = new TeleportClient(this); mTeleportClient.connect(); mTeleportClient.sendMessage("startActivity", null); mTeleportClient.syncInt("myInt",

    12345); setOnGetMessageTask(new TeleportService.OnGetMessageTask { @Override protected void onPostExecute(String path) { if (path.equals("startActivity")){ Intent startIntent = new Intent(this, WearActivity.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startIntent); };}
  5. EventBus.getDefault().post(parcelableObject, this); EventBus.getDefault().postRemote("text", this); EventBus.getDefault().postLocal(object); protected void onCreate(Bundle savedInstanceState) {

    EventBus.getDefault().register(this); } public void onEvent(ParcelableObject parcelableObject){ } public void onEvent(String text){ } BusWear
  6. WearHttp new WearGetText(MainActivity.this).get("http://example.com/text.txt", new WearGetText.WearGetCallBack() { @Override public void onGet(String

    contents) { mTextView.setText(contents); } @Override public void onFail(final Exception e) { mTextView.setText(e.getMessage()); } });
  7. AndroidWearScripts adb forward tcp:4444 localabstract:/adb-hub adb connect localhost:4444 adb -s

    localhost:4444 <command> ./main.sh <optional Id> ./screenshot.sh ./install.sh <apk_file> ./listPackages.sh ...
  8. Exception handling <service android:name=".wear.service.ErrorService" android:process=":error"/> public class WearableApp extends Application

    { private Thread.UncaughtExceptionHandler mWearUEH = new Thread.UncaughtExceptionHandler() { public void uncaughtException(final Thread thread, final Throwable ex) { //... startService(errorIntent); } }; @Override public void onCreate() { Thread.setDefaultUncaughtExceptionHandler(mWearUEH); } } goo.gl/o46Z1u
  9. • Acceleration (m/s2) • Magnetic Field (μT) • Gyroscope (rad/s)

    • Proximity (cm) Sensors • Temperature (°C) • Pressure (hPa) • Humidity (%) • Light (lx) • Heartrate
  10. Sensors - calculated • Acceleration (m/s2) • Magnetic Field (μT)

    • Gyroscope (rad/s) • Proximity (cm) • Temperature (°C) • Pressure (hPa) • Humidity (%) • Light (lx) • Heartrate • Steps • Significant Motion • Gravity • Linear Acceleration • Vector Rotation (x3)
  11. GridViewPager- has beautiful background with parallax effect Here be dragons...

    isRound() - works only with English language. which sometimes disappears.