LoginSignup
2
3

More than 5 years have passed since last update.

AndroidでRemoteControlClientが消えない場合

Posted at

概要

ロック画面に音楽の再生コントローラーを出すときに使う
RemoteControlClientですが
普通に表示したり操作する記事に関しては
WEB記事に挙がったりしていますが
最後に消す方法が載ってなかったりするのでメモ

症状

RemoteControlの解除とされる
unregisterRemoteControlClient(RemoteControlClient)をしても
ロック画面に表示したRemoteControlが消えない。

対処法

Registを解除するだけでは消えない。
ちゃんと消すにはPlaybackSteteをPLAYSTATE_STOPPED
変更してあげる必要がある。

// mRemoteControlClientとmAudioManagerは取得済み
mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
mAudioManager.unregisterRemoteControlClient(mRemoteControlClient);

関連

止める以前に表示させる実装はこちらの連載記事参照のこと
Androidで動く携帯Javaアプリ作成入門(30):Androidアプリでマルチメディアを扱うための基礎知識 (3/3) - @IT

もう5系のAndroidから非推奨なので、使うことも少ないかも知れませんがTipsまで。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3