Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Android近距離通信のあれこれ
Search
Takuya Ohashi
February 15, 2018
550
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Android近距離通信のあれこれ
Takuya Ohashi
February 15, 2018
More Decks by Takuya Ohashi
See All by Takuya Ohashi
冴えない彼女の育て方から学ぶ情熱と合理性の使い分け
pg0084
0
560
モバイルアプリでの Amazon Cognito のすゝめ
pg0084
2
550
決戦Kotlinコンバート
pg0084
0
500
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
37
7.4k
Making Projects Easy
brettharned
120
6.7k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
680
Prompt Engineering for Job Search
mfonobong
0
450
KATA
mclloyd
PRO
35
15k
Exploring anti-patterns in Rails
aemeredith
3
500
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
520
Making the Leap to Tech Lead
cromwellryan
135
10k
Transcript
Androidで用意されている 端末との近距離通信のあれこれ Mobile Act Osaka #3 @pg0084
・オオハシタクヤ @pg0084 ・フェンリルに所属 Androidエンジニア ・静岡県浜松市出身 ・趣味はマクドナルド 自己紹介
Androidの端末間近距離通信について調べてみた
やりたいこと 近距離の端末にメッセージを送る オフライン対応 1対多通信
Android4.0から追加されたNFCを使った通信技術 Android 4.1以降ではNFCで通信を開始したあと はBluetoothに切り替えてコンテンツを送信する 方式になる 「タップしてビーム」これが自分の中で話題に AndroidBeam
良い点 AndroidOSの機能のため、受信側が同じアプリを入れていなくても 良い インターネット接続がなくても通信ができる 比較的大きいデータも早く送受信ができる
NFCなので本当に近くないとできない AndroidBeamの設定がデフォルトでONになっていない端末 が多い 悪い点
条件 近距離の端末にメッセージを送る 〇 オフライン対応 〇 1対多通信 △
Nearby Messages API Google API Console 2015年に公開 Bluetooth、Wi-Fi、人間の耳には聞こえない 音を使って情報を共有を可能にする API
API Keyが必要 iOSのAPIも公開されてます
良い点 近距離の知らない人とも通信ができる OSの隔たりがない (Android、iOSに対応)
オフラインでの利用が不可 耳に聞こえない音と言ったがばっちり音が聞こえる端末があ るらしい(聞いたことない) 100KBまでのデータの送受信(悪い点?) 悪い点
条件 近距離の端末にメッセージを送る ◎ オフライン対応 × 1対多通信 〇
Nearby Connection API 「Google I/O 2017」で発表、バージョンアップされた 完全オフライン対応 通信は「1:N型」と「M:N型」の2種類。 WiFi, Bluetooth
LE & Classic Bluetoothを利用して接続
条件 近距離の端末にメッセージを送る 〇 オフライン対応 〇 1対多通信 〇
Nearby Connection API 実装 AndroidManifest.xml ConnectionsClient
Nearby Connection API 実装 受信側 端末を検出可能状態にする 接続の結果を確認
Nearby Connection API 実装 受信側 接続の要求を受信、接続要求に応じる データの受信 ※rejectConnection()で拒否
Nearby Connection API 実装 送信側 端末を検出を開始 接続の検出、接続要求をする
Nearby Connection API 実装 送信側 データの送信(テキスト) StreamやFileデータもPayloadで送受信可能
良い点 オフラインでの利用が可能 近距離の知らない人とも通信ができる 比較的大きなデータのやりとりも可能
悪い点 GooglePlayService依存
超近距離ですぐ通信を開始する → AndroidBeam Android、iOS隔たりない軽いデータのやりとり → NearbyMessages API、 オフラインでのデータのやりとり → NearbyConnection
API まとめ
ご清聴ありがとうございました