Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
土掘るHaptics
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
cffYoHa
October 21, 2025
Programming
120
0
Share
土掘るHaptics
potatotips #93 iOS/Android開発Tips共有会
cffYoHa
October 21, 2025
More Decks by cffYoHa
See All by cffYoHa
Grid表示のレイアウトで Flow layoutsを使う
cffyoha
1
390
Other Decks in Programming
See All in Programming
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
380
From Formal Specification to Property Based Test
ohbarye
0
2.4k
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
490
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
340
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
360
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
Back to the roots of date
jinroq
0
810
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
170
Agentic Elixir
whatyouhide
0
450
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
460
Featured
See All Featured
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
230
[SF Ruby Conf 2025] Rails X
palkan
2
1k
RailsConf 2023
tenderlove
30
1.4k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
300
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
350
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
500
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
800
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Transcript
土掘るHaptics potatotips #93 @cffYoHa
自己紹介 2
3 株式会社スマートバンク Android エンジニア YoHa(ようは) @cffYoHa
Haptics(触覚フィードバック)とは 4
5 Hapticsの例 https://source.android.com/docs/core/interaction/haptics/haptics-ux-foundation?hl=ja#rich-haptics https://www.youtube.com/live/l3yDd3CmA_Y?si=l69zbw11WHS9KnTN&t=277 例① - 文字選択で、指をスライドさせた際に文字 数分の振動が伝わる 例② -
Material3Expressiveにおいて 通知スタックを消す際などに リッチな振動体験が提供
Hapticsの分類 大音量で不快な可聴ノイズ 低品質な印象(安くて壊れた電話 など)を与える 非連続の状態変化 (電源オン / オフなど)の 感覚をサポート
単一の振動刺激に依存しない 豊かなハプティクス https://source.android.com/docs/core/interaction/haptics/haptics-ux-foundation 6
7 https://github.com/android/platform-samples/tree/main/samples/user-interface/haptics 公式サンプル
8 8
実装一例 AI埋蔵金チェッカー ワンバンが支出を分析し、 その中から節約ポテンシャルとなる「埋蔵金」を発見する機能 RiveファイルからEventを受け取ったタイミング(スコップで地面を掘る 時)にHapticsFBが発生 9
https://speakerdeck.com/yokomii/rivetegong-shi-quan-wointarakusiyonsuru yokomii さんの発表資料 10
Android16におけるHapticsAPIの変化 11
- BasicEnvelopeBuilder - WaveformEnvelopeBuilder 振動の振幅(Envelope)を制御することで、ス ムーズな増減が可能 新たなRich Hapticsが追加 https://developer.android.com/develop/ui/views/haptics/custom-haptic-effects#rocket-launch 12
触るぞ 💪 13
Envelope effectsが使えるかの確認方法 14 - Android 16以上 - デバイスがEnvelope effectsに対応していること -
areEnvelopeEffectsSupported()で確認可能
手持ちに最新Android16端末なかったので購入 15
対応してませんでした😭 16
既存のHapticsAPIで実装します😇 17
• DEFAULT_AMPLITUDE ◦ デバイスに設定されている標準の振動レベル ◦ ハードウェアの性能によって、0〜255 の中で指定される • createOneShot()のようなシンプルな バイブレーションのオン
/ オフは 利用すべきではないらしい 現在の実装 val vibrator = context.getSystemService(Vibrator::class.java) val vibrationEffect = VibrationEffect.createOneShot( 200, VibrationEffect.DEFAULT_AMPLITUDE, ) vibrator.vibrate(vibrationEffect) https://developer.android.com/develop/ui/views/haptics/haptics-principles 18
土を掘るということ 1. スコップで地面を刺す 2. 土の中をスコップが進む 3. スコップを上方向に持ち上げ、 地中からでる 19
ハードウェアごとに再現できる モーター性能が異なる 最大値(255)に近い値で不快なノイズが 発生することも そもそもこんなコード書くな 再現してみた① val timings = longArrayOf(
0, // 初期待機 35, // 刺さる 15, // 休止 15, // 掘る1 10, // 休止 17, // 掘る2 8, // 休止 20, // 掘る3 12, // 休止 30, // 持ち上げる 30, // 休止 ) val amplitudes = intArrayOf( 0, // 初期待機 220, // 刺さる 0, // 休止 100, // 掘る1 0, // 休止 140, // 掘る2 0, // 休止 180, // 掘る3 0, // 休止 255, // 持ち上げる 0, // サイクル間休止 ) vibrator.vibrate(VibrationEffect.createWaveform(timings, amplitudes, -1)) 20
- HapticFeedbackConstants - ハードウェアの操作(ボタン押下やキーボード入力)によく使われているため、 ユニークなFB体験にならなそう - 一方で、事前定義済みのアクションに該当する場合は、 一貫したユーザー操作体験を提供可能 -
VibrationEffect - 単発の振動から複雑な波形まで様々 - VibrationEffect.Composition(Android 11以降)を使うことで振動を合成可能 - Android16から追加のEnvelop effectsもVibrationEffectの一部 Hapticの定数を利用する 21
- Riveファイルの変更に応じて振動タイミン グを細かく修正する必要性 再現してみた②-1 val effect =
VibrationEffect.startComposition() // スコップを刺す .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_FALL, 0.5f) // スコップが地中を進む(100ms 後) .addPrimitive(VibrationEffect.Composition.PRIMITIVE_TICK, 0.5f, 100) // スコップを持ち上げる(150ms 後) .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, 1.0f, 150) .compose() vibrator.vibrate(effect) 22
よくわからんし、ずっと振動してるだけだな... 23
- シンプルが一番よかった - PRIMITIVE_QUICK_RISE - 重力に逆らって素早く上向きに動く様子を シュミレートする触覚効果 再現してみた②-2 val effect
= VibrationEffect.startComposition() .addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, 1.0f, 0) .compose() vibrator.vibrate(effect) https://developer.android.com/reference/android/os/VibrationEffect.Composition 24
まとめ 25
まとめ - Hapticsの定数を使う - 簡単に多様なデバイスで動作するHaptics体験を提供できる - ボタンやキーボード操作などはHapticFeedbackConstants - それらで表現できないものはVibrationEffect -
Hapticsは、デバイスの進化とともに豊かになった - OSVerとそのデバイスが物理的に表現可能なHapticsか、areXxxSuported() APIで確認する - 使いすぎると、ユーザーがHapticsをオフにする可能性もある - Envelope周りのHapticsAPIを触りたいならGalaxy Z Fold 7は買うな 26
Good Haptics! 27