android wear

58
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Upload: hidecheck

Post on 19-Aug-2014

978 views

Category:

Engineering


2 download

DESCRIPTION

What's Android Wear.

TRANSCRIPT

Page 1: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Page 2: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Agenda

➢ What’s Android Wear➢ Android Wearでできること

➢ Googleが描くコンセプト

➢ アプリケーション開発に必要な環境

➢ プロジェクトを作成する

➢ Android Ware Demo

Page 3: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

What’s Android Wear ??

Page 4: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

服やカバン、腕時計ののように身につけて(wear)利用するコンピュータ

ウェアラブルとは

Page 5: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

What’s Android Wear

➢ ウェアラブル端末用のAndroidプラットフォーム○ http://developer.android.com/wear/index.html

➢ 主に腕時計として使われている

LG G WatchMoto 360

Page 6: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ 四角と丸

エミュレータも用意されている

Page 7: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wearでできること

Page 8: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wearでできること

➢ 2つのUIモデル○ Context Stream○ Cue Card

Page 9: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Content Stream

➢ Notificationを表示○ Receive Voice Reply○ アプリケーションから○ ジオフェンスと連携○ センサーから

Page 10: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Cue Card

➢ Cue Card○ 「OK Google」または ”g” アイコンをタップ○ アクション一覧が表示される

OK Google

Page 11: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wear SDKでできること

➢ Build Custom UI➢ Send Data➢ Control Sensors➢ Voice Action

Page 12: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Build Custom UI

➢ Notificationを重ねる➢ 背景画像を設定➢ 複数ページ対応

Page 13: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Send Data

➢ メッセージを送る

Page 14: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Control Sensors

➢ センサー入力○ センサデータを収集し、Androidのウェアラブル上にリアルタイムに表

示します

Page 15: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Voice Action

➢ 音声入力に対応○ デバイスをタッチしなくても入力ができる

Page 16: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Googleが描くコンセプト

Page 17: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Google Now を中心に

➢ Information that moves with you

Page 18: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

電車の中で

4 stopsto: Jacson St.9 miniites to destination

Page 19: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

タクシーで

Mega TaxiPickup 149 Linden Ave,Long Beach CA908024 minutes away

Page 20: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

ビーチで

Warning !

Jellyfish reported in areaStay out of the water

Nearby BeachesZuma beach 3-5 ftCounty Line Beach 2-4 ftEl Porto Beach 1-3 ft

Page 21: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

空港で

LAX→JFKDeparts 12:55pmTerminal 3, Gate 72Flight 867

Page 22: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

試合結果を聞いてみたり

what's theSyracuse score ?

Syracuse 28Virginia 27

Page 23: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Google Wearは教えてくれる

➢ 今ここで何がしたいをサポート○ わざわざ調べなくても勝手に教えてくれる

➢ スマフォを取り出しての操作が不要○ 手が濡れてても平気○ ハンドルを握ってても平気

Page 24: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

アプリケーション開

発に必要な環境

Page 25: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

開発環境

➢ デバイス○ Android

■ Android 4.3以上

➢ 開発ツール○ Android SDK Tools 22.6 or higher○ Eclipse ADT Plugin or higher○ Android Studio 0.5.1 or higher○ Android Wear Preview

➢ Android Wear○ エミュレータ

Page 26: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

開発者登録

➢ Android Wear Developer Previewのための開発者登録○ 登録手順

■ フォームから開発者情報を登録■ メールが送られてくる■ SDKをダウンロードする

Page 27: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wear Previewを入手する

➢ 手順○ テスター登録をする

■ Sign Up Confirmationメールから登録ページヘ移動

○ Google Play から インストール■ 手持ちのAndroid 端末にインストールする

Page 28: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

エミュレータの作成

➢ イメージの取得○ Android SDK Managerを起動○ Android Wear ARM EABI v7a System Image をインストールする

Page 29: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

エミュレータの作成

➢ Device➢ CPU/ABI➢ Skin

Page 30: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ 選択して[Start...]

起動する

Page 31: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

起動完了!

Page 32: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wearと接続する

➢ Android Wear Previewを通して実機とエミュレータを接続する○ Android 4.3以上の端末が必要

$ adb -d forward tcp:5601 tcp:5601

Page 33: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ 手順○ エミュレータを起動する○ AndroidをPCに接続○ Android Wear Previewを起動

Android Wearと連携する

接続されていない状態

Page 34: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ 手順(続き)➢ Androidとエミュレータを接続する方法

○ ターミナルから次のコマンドを実行

○ [Connect]ボタンをクリック

Android Wearと接続する

$ adb -d forward tcp:5601 tcp:5601

Page 35: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ 接続されたことを確認○ [Connected]と表示されている○ エミュレータのアイコンが “g” になっている

Android Wearと接続する

接続されている状態

Page 36: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wearと連携する

➢ Android to Android Wear○ AndroidのNotificationはそのまま表示される

Page 37: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wearと連携する

➢ Android Wear to Android○ 表示されたNotificationを操作する○ [Open]をクリックするとアプリが起動する

メッセージが表示される

 横へフリック

上へフリック

 クリック!

Page 38: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

1. AndroidでNotificationが表示される2. Previewアプリが検知3. Android Wearに通知

Notification通知の流れ(Preview)

Notification!

アプリ

GCM

現在地

Page 39: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ サンプルアプリ○ ElizaChat○ WearableNotificationsSample○ RecipeAssistant

サンプルアプリを動かす

Page 40: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ サンプルをビルドする○ ターミナルを起動○ アプリケーションプロジェクトディレクトリまで移動する

■ ここではWearableNotificationsSample○ gradlewを実行する○ apkファイルをインストールする

サンプルアプリケーションのビルド

$ cd [Android WearPreview]/samples/WearableNotificationsSample$ chmod +x graidlew$./gradlew...BUILD SUCCESSFUL

Total time: 5.348 secs$ adb -s 079c74c8 install build/apk/WearableNotificationsSample-debug-unaligned.apk6483 KB/s (726078 bytes in 0.109s) pkg: /data/local/tmp/WearableNotificationsSample-debug-unaligned.apkSuccess

Page 41: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

サンプルアプリケーションの起動

➢ アプリ一覧から起動する

クリック

Page 42: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

➢ シンプルなチャットアプリ

ElizaChat

音声入力の代わりにキーボード入力

Page 43: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

WearableNotificationsSample

➢ 様々なタイプのNotificationを表示する

Page 44: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

WearableNotificationsSample

設定を変えて実行

Page 45: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

WearableNotificationsSample

Example reply action

音声入力の代わりにキーボード入力

Page 46: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

WearableNotificationsSample

Open

Page 47: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Recipe Assistant

料理のレシピと手順を表示

Page 48: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

プロジェクトを作成する

Page 49: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習アプリケーションの説明

➢ アプリケーションの説明○ ボタンをクリックするとNotificationが表示される○ Android WearのOpenアイコンをタップすると画面が表示される

クリック

Notificationが表示される

画面をスワイプ

タップ

Page 50: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習シンプルなNotification

➢ IDE○ Android Studio V0.5.8

➢➢ 手順

○ 1. ライブラリの追加○ 2. Notificationから起動されるActivityを追加○ 3. MainActivityにNotification表示処理を追加

Page 51: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習

➢ 1. ライブラリの追加build.gradleの修正○ Developer Previewに含まれている

”wearable-preview-support.jar”をプロジェクトのlibsにコピーする

○ build.gradleの修正■ dependenciesに以下のjarを追加する

● /android-support-v4.jar● wearable-preview-support.jar

アプリケーションの作成

dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])compile "com.android.support:support-v4:19.1.+"compile files('../libs/wearable-preview-support.jar')

}

Page 52: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習

➢ 2. Notificationから起動されるActivityを追加○ Activity名:ViewEventActivity○ レイアウト

アプリケーションの作成

Page 53: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習アプリケーションの作成

➢ 3. MainActivityにNotification表示処理を追加○ Buttonが押された時の処理を追加する

■ 通常のNotificationの表示処理と同じ

Intent viewIntent = new Intent(this, ViewEventActivity.class); viewIntent.putExtra("eventId", eventId); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(eventTitle) .setContentText(eventMessate) .setContentIntent(viewPendingIntent);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

notificationManager.notify(notificationId, notificationBuilder.build());

Page 54: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習Actionをカスタマイズ

Actionをカスタマイズして、アイコンを変更する

Page 55: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習Actionをカスタマイズ

➢ MainActivityにNotification表示処理を修正

Intent viewIntent = new Intent(Intent.ACTION_VIEW);Uri uri = Uri.parse("content://contacts/people/");viewIntent.setData(uri);

PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(eventTitle) .setContentText(eventMessate) .setContentIntent(viewPendingIntent) .addAction(android.R.drawable.sym_contact_card, "Contacts", viewPendingIntent);

Page 56: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習Wearの新機能を使う

Iconを非表示

// Create a WearablesNotification.Builder to add special functionality for wearablesNotification notification = new WearableNotifications.Builder(notificationBuilder) .setHintHideIcon(true) .build();

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

notificationManager.notify(notificationId, notification);

Page 57: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

実習Wearの新機能を使う

Reply Input

// Create the remote inputRemoteInput remoteInput = new RemoteInput.Builder("reply") .setLabel("Reply") .build();// Create wearable notification and add remote inputNotification replyNotification = new WearableNotifications.Builder(replyNotificationBuilder) .addRemoteInputForContentIntent(remoteInput) .build();

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

notificationManager.notify(1, replyNotification);

Page 58: Android Wear

Copyright © 2014 TOPGATE Corporation. All Rights Reserved.

Android Wear Demo