LoginSignup
12
15

More than 5 years have passed since last update.

Multi WindowのPicture-in-pictureを試す方法を見つけたメモ

Last updated at Posted at 2016-09-18

概要

ちょっと詳細は置いておいてPicture in pictureを利用できることがわかったので、メモとして書いておきます。
何か間違っていたら指摘お願いします。
Picture-in-pictureは常に上に一つのアプリを表示させることができます。
( // 常にPokemon GOを起動させておきたいという不純な動機で調べたりしていないです。)

デバッグ用の機能だと思われるので自己責任でお願いします。

手順

force_resizable_activitiesをtrueにする

まず全てのActivityをresizeableにする以下の操作をします。

adb shell settings put global force_resizable_activities 1

これをした後に端末を再起動してください。

これをするとActivityManagerServiceの中でPictureInPictureが有効になるようです。

mSupportsPictureInPicture = supportsPictureInPicture || forceResizable;

Activity Stackのidを確認する

adb shell am stack listを入力して
Picture-in-pictureで起動したいアプリがある stack idをメモします。 (1など)

$ adb shell am stack list
Stack id=1 bounds=[0,0][1080,1920] displayId=0 userId=0
  taskId=3236: com.android.settings/com.android.settings.Settings bounds=[0,0][1080,1920] userId=0 visible=true topActivity=ComponentInfo{com.nianticlabs.pokemongo/com.unity3d.player.UnityPlayerNativeActivity}
  taskId=3235: com.nianticlabs.pokemongo/com.unity3d.player.UnityPlayerNativeActivity bounds=[0,0][1080,1920] userId=0 visible=true topActivity=ComponentInfo{com.nianticlabs.pokemongo/com.unity3d.player.UnityPlayerNativeActivity}

Stack id=0 bounds=[0,0][1080,1920] displayId=0 userId=0
  taskId=3234: com.google.android.googlequicksearchbox/com.google.android.launcher.GEL bounds=[0,0][1080,1920] userId=0 visible=false topActivity=ComponentInfo{com.android.systemui/com.android.systemui.recents.RecentsActivity}
  taskId=3237: com.android.systemui/com.android.systemui.recents.RecentsActivity bounds=[0,0][1080,1920] userId=0 visible=false topActivity=ComponentInfo{com.android.systemui/com.android.systemui.recents.RecentsActivity}

Picture-in-pictureする

1がstack idで その後に LEFT,TOP,RIGHT,BOTTOMと続きます。

adb shell am stack move-top-activity-to-pinned-stack 1 0 0 400 800

これでこんな感じになります。
image

ちなみになぜmove-top-activity-to-pinned-stackでPicture in pictureなのかはわかりませんが、enterPictureInPictureMode()メソッド内で、moveActivityToPinnedStackLocked()を呼び出しているので内部的にはそう呼ぶのかもしれません。
https://github.com/android/platform_frameworks_base/blob/nougat-release/services/core/java/com/android/server/am/ActivityManagerService.java#L7536

解除は adb shell am stack remove スタックidでいけるはずです

おまけ

ここだけメモすればOKかも

あるアプリ(pokemongoというパッケージが含まれるもの)をPicture-in-pictureで表示する

adb shell am stack list|awk '/Stack id.*/{laststack = substr($2,4)} /.*pokemongo.*/{print laststack;exit}'|xargs -I^ adb shell am stack move-top-activity-to-pinned-stack \^ 0 0 100 150

あるアプリのPicture-in-pictureを解除する

adb shell am stack list|awk '/Stack id.*/{laststack = substr($2,4)} /.*pokemongo.*/{print laststack;exit}'|xargs -I^ adb shell am stack remove \^

12
15
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
12
15