Last active
August 29, 2015 14:07
-
-
Save shunirr/3bdcf52d7a16a899b907 to your computer and use it in GitHub Desktop.
Revisions
-
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -93,8 +93,26 @@ Notification n = new NotificationCompat.Builder(context) * 返信のメニューを作ったところで返信する内容をユーザは入力する必要がある * RemoteIntent を使うと音声入力できるようになる * デフォルトの選択 (はい/いいえ) とかも設定できる * これで入力した文字列は Intent の `NotificationActivity.EXTRA_VOICE_REPL` という所に入っている ```java RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel("xx会議に参加しますか?") .setChoices(new String[] {"はい", "いいえ"}) .build(); ``` ```java Notification notification = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("出席確認") .setContentText("xx会議の出席確認です") .extend(new NotificationCompat.WearableExtender().addAction(action)) .build(); ``` ## Notification * Notification にページを作ることが出来る -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 47 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -115,6 +115,26 @@ Notification n = new NotificationCompat.Builder(context) * 送れるのは文字列だけ * Wear 上のボタン操作を電話機に通知するときとかに使う ### データの送信 ```java MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient, node, START_ACTIVITY_PATH, null).await(); ``` ### データの受信 ```java @Override public void onMessageReceived(MessageEvent messageEvent) { if (START_ACTIVITY_PATH.equals(messageEvent.getPath())) { Intent intent = new Intent(this, WatchActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } ``` ## Data API * Android Wear と電話機でデータをやりとりする時に使う API @@ -123,6 +143,33 @@ Notification n = new NotificationCompat.Builder(context) ### データの変更 ```java PutDataMapRequest dataMap = PutDataMapRequest.create(COUNT_PATH); dataMap.getDataMap().putInt(COUNT_KEY, count++) PutDataRequest request = dataMap.asPutDataRequest(); PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mGoogleApiClient, request); pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { Log.d(TAG, "count updated:" + count); } }); ``` ### データの変更通知 ```java @Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { DataItem dataItem = event.getDataItem(); if (COUNT_PATH.equals(dataItem.getUri().getPath())) { DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap(); int count = dataMap.getInt(COUNT_KEY); } } } ``` ## 参考文献 -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -121,6 +121,9 @@ Notification n = new NotificationCompat.Builder(context) * Message API と違って Bundle みたいなものを "同期させる" * やりとりではなくて同期なので、中身を書き換えると変更イベントが飛んできたりする ### データの変更 ## 参考文献 * http://www.android.com/intl/ja/wear/ -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,16 +6,14 @@  ## Android Wear について Android と連携して良い感じにしてくれる腕時計型デバイス。 * 通知転送してくれて便利 * 通知や着信をスルーすることが減る * 音声入力できてわりと精度がいい * Yo ができる  -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # 最近買った腕時計の話 いつも使っている glide.so というサービスが滅びたので、このままやります。 ## LG G Watch 買いました  -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 22 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,21 @@ Android と連携して良い感じにしてくれる腕時計型デバイス。  ## Android Wear 端末 * LG G Watch * Moto 360  まるい * SmartWatch 3  ## Android Wear の仕組み * Android のサブセット OS が動いてる @@ -52,6 +67,13 @@ Android と連携して良い感じにしてくれる腕時計型デバイス。 adb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444 ``` ## リソース 丸い端末と四角い端末のリソースファイルをそれぞれ定義できる。腕時計の形によって適宜つかわれる模様 (丸い時計を持ってないので検証してない) 。 * wear_activity_rect.xml * wear_activity_round.xml ## Notification Android の通知が全部転送されてくるけど、 Wear 用にフラグを立てると、その通知に返信とかの機能を付けることが出来る。 -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # 最近買った腕時計の話 ## LG G Watch 買いました @@ -71,13 +71,13 @@ Notification n = new NotificationCompat.Builder(context) * 返信のメニューを作ったところで返信する内容をユーザは入力する必要がある * RemoteIntent を使うと音声入力できるようになる * これで入力した文字列は Intent の `NotificationActivity.EXTRA_VOICE_REPL` という所に入っている ## Notification * Notification にページを作ることが出来る * Google Hangouts とかだと、発言の通知→最近の発言 (20 件くらい) → 返信メニューという風になってる * スタックを作ることが出来る * 通知を未読のまま次の通知が来たときとかに「他 2 件の通知」というような感じに表示させることができる ## Wear 上で Activity を作る -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 8 additions and 43 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,7 @@ Android と連携して良い感じにしてくれる腕時計型デバイス。 ## Twitter とかのデモ ## 開発 買ってからあまり時間が経っていないので Hello World 動かしたくらいだけどザックリ調べたことを紹介します。 @@ -91,53 +91,18 @@ Notification n = new NotificationCompat.Builder(context) * Android Wear と電話機でデータをやりとりする時に使う API * 送れるのは文字列だけ * Wear 上のボタン操作を電話機に通知するときとかに使う ## Data API * Android Wear と電話機でデータをやりとりする時に使う API * Message API と違って Bundle みたいなものを "同期させる" * やりとりではなくて同期なので、中身を書き換えると変更イベントが飛んできたりする ## 参考文献 * http://www.android.com/intl/ja/wear/ * http://ja.wikipedia.org/wiki/Android_Wear * http://www.buildinsider.net/mobile/androidwear/01 * https://developer.android.com/reference/com/google/android/gms/wearable/MessageEvent.html * https://developer.android.com/reference/com/google/android/gms/wearable/DataMap.html -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,9 @@ ## LG G Watch 買いました  * [買った時の話](http://shunirr.hatenablog.jp/entry/2014/10/07/160003) ## Android Wear について -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Android と連携して良い感じにしてくれる腕時計型デバイス。 * Yo ができる * 音声入力できてわりと精度がいい  ## Android Wear の仕組み -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,9 +11,12 @@ Android と連携して良い感じにしてくれる腕時計型デバイス。 * 通知転送してくれて便利 * 通知や着信をスルーすることが減る * Yo ができる * 音声入力できてわりと精度がいい ![http://instagram.com/p/tfNgRFjqlL/media/?size=l]() ## Android Wear の仕組み * Android のサブセット OS が動いてる -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 39 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,27 +45,63 @@ Android と連携して良い感じにしてくれる腕時計型デバイス。 * PC と USB などで接続された電話機を経由して Bluetooth でデバッグ接続できる * IDE とかがよしなに繋いでくれたりはしないので自分でコマンドを叩いて接続する ```sh adb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444 ``` ## Notification Android の通知が全部転送されてくるけど、 Wear 用にフラグを立てると、その通知に返信とかの機能を付けることが出来る。 PendingIntent を作って起動する Activity を定義しておく。 ```Java Notification n = new NotificationCompat.Builder(context) .setContentTitle("新着メッセージがあります") .setContentText("xxさんからメッセージが届いています") .setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pIntent) .addAction(R.drawable.ic_launcher, "返信", pendingIntent) .build(); ``` ## RemoteInput * 返信のメニューを作ったところで返信する内容をユーザは入力する必要がある * RemoteIntent を使うと音声入力できるようになる * これで入力した文字列は `NotificationActivity.EXTRA_VOICE_REPL` という所に入っている ## Notification * Notification にページを作ることが出来る * Google Hangouts とかだと、発言の通知→最近の発言 (20 件くらい) → 返信メニューという風になってる * スタックを作ることも出来る * 通知を未読のまま次の通知が来たときとかに「他 2 件の通知」というような感じに表示させることができる ## Wear 上で Activity を作る * もちろん中身は Android なので Activity を動かすこともできる * 使えない View 部品もあるけど、だいたい使えるらしい * WebView すらつかえる * ちなみに Wear 上で動くウェブブラウザアプリもある ## Message API * Android Wear と電話機でデータをやりとりする時に使う API * 送れるのは文字列だけ * 電話機の音楽プレイヤーを時計で操作するとか、そういうときに使う感じ https://developer.android.com/reference/com/google/android/gms/wearable/MessageEvent.html ## Data API * Android Wear と電話機でデータをやりとりする時に使う API * Message API と違って Bundle みたいなものを "同期させる" * やりとりではなくて同期なので、中身を書き換えると変更イベントが飛んできたりする * 音楽プレイヤーの曲一覧とかを入れたりできそう https://developer.android.com/reference/com/google/android/gms/wearable/DataMap.html ## http://www.android.com/intl/ja/wear/ http://ja.wikipedia.org/wiki/Android_Wear -
shunirr revised this gist
Oct 9, 2014 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,6 +51,17 @@ adb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444 ## Notification Android の通知が全部転送されてくるけど、 Wear 用にフラグを立てると、その通知に返信とかの機能を付けることが出来る。 ```Java Notification n = new NotificationCompat.Builder(context) .setContentTitle("新着メッセージがあります") .setContentText("xxさんからメッセージが届いています") .setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pIntent) .addAction(R.drawable.ic_launcher, "返信", pIntent) .build(); ``` ## RemoteInput -
shunirr renamed this gist
Oct 9, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
shunirr revised this gist
Oct 9, 2014 . 2 changed files with 93 additions and 70 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ 最近買った腕時計の話 ## LG G Watch 買いました (LG G Watch の画像) * http://shunirr.hatenablog.jp/entry/2014/10/07/160003 ## Android Wear について Android と連携して良い感じにしてくれる腕時計型デバイス。 * 通知転送してくれて便利 * Yo ができる * 音声入力できてわりと精度がいい ## Android Wear の仕組み * Android のサブセット OS が動いてる * Wear アプリは電話機アプリと別プロジェクトで開発するし apk も別になる * インストールやデバッグも独立して行う * なのでアプリのアンインストールができない (`adb uninstall hoge` とかすると消せる) ## アプリの配布 * しかし単体で配布できない * 単体で Google Play にアクセスできないので * アプリを配布する場合は電話機アプリと一緒に配布する ## アプリの起動 * 通知からの返信 * 音声入力 * ランチャーアプリを入れればタッチでアプリ起動ができる ## Twitter とかのデモ ## 開発について 買ってからあまり時間が経っていないので Hello World 動かしたくらいだけどザックリ調べたことを紹介します。 ## 開発環境 * Wear アプリは独立して動いているので PC と直接 adb で繋がりたい * PC と USB などで接続された電話機を経由して Bluetooth でデバッグ接続できる * IDE とかがよしなに繋いでくれたりはしないので自分でコマンドを叩いて接続する ``` adb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444 ``` ## Notification ## RemoteInput ## Activity http://www.android.com/intl/ja/wear/ http://ja.wikipedia.org/wiki/Android_Wear http://www.buildinsider.net/mobile/androidwear/01 ---- Chromecast の話 ## Chromecast について 中でウェブブラウザが動いてる 動画もウェブアプリ上で再生する Default で動画や音楽を再生する Receiver アプリはある ## Android で Chromecast Chromecast で調べると CastCompanionLibrary-android というのがでてきて使えそうに見えるが、結構 CastCompanion-Android というアプリに依存してるので、抽象度があんまり高くない いろいろやると結局自分で似たようなの作るハメになる。 http://qiita.com/Katsumi/items/08330778a2e7c06178d6 http://qiita.com/KazuyukiEguchi/items/ea137f4419d36d070535 ## 注意点 * ActionBarSherlock を廃止して AppCompat に移行した This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,70 +0,0 @@ -
shunirr created this gist
Oct 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ 最近買った腕時計の話 ## LG G Watch 買いました最高!!! * http://shunirr.hatenablog.jp/entry/2014/10/07/160003 ## Android Wear について * 通知転送してくれて便利 * Yo ができる ## Android Wear の仕組み Android のサブセット OS が動いてる アプリの配布 インストールは電話機アプリの apk に同梱する 電話機とは独立してる アンインストールができない ## Twitter とかのデモ ## 開発 ## Notification ## RemoteInput ## Activity http://www.android.com/intl/ja/wear/ http://ja.wikipedia.org/wiki/Android_Wear http://www.buildinsider.net/mobile/androidwear/01 ---- Chromecast の話 ## Chromecast について 中でウェブブラウザが動いてる 動画もウェブアプリ上で再生する Default で動画や音楽を再生する Receiver アプリはある ## Android で Chromecast Chromecast で調べると CastCompanionLibrary-android というのがでてきて使えそうに見えるが、結構 CastCompanion-Android というアプリに依存してるので、抽象度があんまり高くない いろいろやると結局自分で似たようなの作るハメになる。 http://qiita.com/Katsumi/items/08330778a2e7c06178d6 http://qiita.com/KazuyukiEguchi/items/ea137f4419d36d070535 ## 注意点 * ActionBarSherlock を廃止して AppCompat に移行した