android wear
DESCRIPTION
What's Android Wear.TRANSCRIPT
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Agenda
➢ What’s Android Wear➢ Android Wearでできること
➢ Googleが描くコンセプト
➢ アプリケーション開発に必要な環境
➢ プロジェクトを作成する
➢ Android Ware Demo
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
What’s Android Wear ??
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
服やカバン、腕時計ののように身につけて(wear)利用するコンピュータ
ウェアラブルとは
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
What’s Android Wear
➢ ウェアラブル端末用のAndroidプラットフォーム○ http://developer.android.com/wear/index.html
➢ 主に腕時計として使われている
LG G WatchMoto 360
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ 四角と丸
エミュレータも用意されている
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wearでできること
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wearでできること
➢ 2つのUIモデル○ Context Stream○ Cue Card
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Content Stream
➢ Notificationを表示○ Receive Voice Reply○ アプリケーションから○ ジオフェンスと連携○ センサーから
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Cue Card
➢ Cue Card○ 「OK Google」または ”g” アイコンをタップ○ アクション一覧が表示される
OK Google
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wear SDKでできること
➢ Build Custom UI➢ Send Data➢ Control Sensors➢ Voice Action
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Build Custom UI
➢ Notificationを重ねる➢ 背景画像を設定➢ 複数ページ対応
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Send Data
➢ メッセージを送る
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Control Sensors
➢ センサー入力○ センサデータを収集し、Androidのウェアラブル上にリアルタイムに表
示します
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Voice Action
➢ 音声入力に対応○ デバイスをタッチしなくても入力ができる
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Googleが描くコンセプト
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Google Now を中心に
➢ Information that moves with you
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
電車の中で
4 stopsto: Jacson St.9 miniites to destination
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
タクシーで
Mega TaxiPickup 149 Linden Ave,Long Beach CA908024 minutes away
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
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
空港で
LAX→JFKDeparts 12:55pmTerminal 3, Gate 72Flight 867
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
試合結果を聞いてみたり
what's theSyracuse score ?
Syracuse 28Virginia 27
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Google Wearは教えてくれる
➢ 今ここで何がしたいをサポート○ わざわざ調べなくても勝手に教えてくれる
➢ スマフォを取り出しての操作が不要○ 手が濡れてても平気○ ハンドルを握ってても平気
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
アプリケーション開
発に必要な環境
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○ エミュレータ
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
開発者登録
➢ Android Wear Developer Previewのための開発者登録○ 登録手順
■ フォームから開発者情報を登録■ メールが送られてくる■ SDKをダウンロードする
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wear Previewを入手する
➢ 手順○ テスター登録をする
■ Sign Up Confirmationメールから登録ページヘ移動
○ Google Play から インストール■ 手持ちのAndroid 端末にインストールする
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
エミュレータの作成
➢ イメージの取得○ Android SDK Managerを起動○ Android Wear ARM EABI v7a System Image をインストールする
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
エミュレータの作成
➢ Device➢ CPU/ABI➢ Skin
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ 選択して[Start...]
起動する
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
起動完了!
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wearと接続する
➢ Android Wear Previewを通して実機とエミュレータを接続する○ Android 4.3以上の端末が必要
$ adb -d forward tcp:5601 tcp:5601
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ 手順○ エミュレータを起動する○ AndroidをPCに接続○ Android Wear Previewを起動
Android Wearと連携する
接続されていない状態
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ 手順(続き)➢ Androidとエミュレータを接続する方法
○ ターミナルから次のコマンドを実行
○ [Connect]ボタンをクリック
Android Wearと接続する
$ adb -d forward tcp:5601 tcp:5601
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ 接続されたことを確認○ [Connected]と表示されている○ エミュレータのアイコンが “g” になっている
Android Wearと接続する
接続されている状態
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wearと連携する
➢ Android to Android Wear○ AndroidのNotificationはそのまま表示される
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wearと連携する
➢ Android Wear to Android○ 表示されたNotificationを操作する○ [Open]をクリックするとアプリが起動する
メッセージが表示される
横へフリック
上へフリック
クリック!
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
1. AndroidでNotificationが表示される2. Previewアプリが検知3. Android Wearに通知
Notification通知の流れ(Preview)
Notification!
アプリ
GCM
現在地
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ サンプルアプリ○ ElizaChat○ WearableNotificationsSample○ RecipeAssistant
サンプルアプリを動かす
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
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
サンプルアプリケーションの起動
➢ アプリ一覧から起動する
クリック
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
➢ シンプルなチャットアプリ
ElizaChat
音声入力の代わりにキーボード入力
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
WearableNotificationsSample
➢ 様々なタイプのNotificationを表示する
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
WearableNotificationsSample
設定を変えて実行
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
WearableNotificationsSample
Example reply action
音声入力の代わりにキーボード入力
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
WearableNotificationsSample
Open
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Recipe Assistant
料理のレシピと手順を表示
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
プロジェクトを作成する
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
実習アプリケーションの説明
➢ アプリケーションの説明○ ボタンをクリックするとNotificationが表示される○ Android WearのOpenアイコンをタップすると画面が表示される
クリック
Notificationが表示される
画面をスワイプ
タップ
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
実習シンプルなNotification
➢ IDE○ Android Studio V0.5.8
➢➢ 手順
○ 1. ライブラリの追加○ 2. Notificationから起動されるActivityを追加○ 3. MainActivityにNotification表示処理を追加
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')
}
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
実習
➢ 2. Notificationから起動されるActivityを追加○ Activity名:ViewEventActivity○ レイアウト
アプリケーションの作成
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());
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
実習Actionをカスタマイズ
Actionをカスタマイズして、アイコンを変更する
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);
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);
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);
Copyright © 2014 TOPGATE Corporation. All Rights Reserved.
Android Wear Demo