エミュレータでカメラ起動すると映るコレ。

微妙に動いてるんですけど...

何かのキャラなのか、
家にも見えたりするだけども、動いてるし。
一体、何なのっ?!
サンプル見てましたが。

android-PictureInPicture/README.md at master · googlesamples/android-PictureInPicture
...。
ただ、縮小されたActivityを常駐的に端末画面の上に載せたいだけなのですが...。
BlankActivityで実装するだけ。
これぐらいまで。

AndroidManifest.xml
<activity android:name=".MainActivity"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (VERSION.SDK_INT >= VERSION_CODES.O) {
text.setOnClickListener {
val params = PictureInPictureParams.Builder().apply {
setAspectRatio(Rational(4, 3))
}.build()
enterPictureInPictureMode(params)
}
}
}
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean,
newConfig: Configuration) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
if (isInPictureInPictureMode) {
text.text = "small"
setFullScreen(true)
} else {
text.text = "normal"
setFullScreen(false)
}
}
private fun setFullScreen(on: Boolean) {
window.decorView.systemUiVisibility = if (on) {
SYSTEM_UI_FLAG_LAYOUT_STABLE or
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
SYSTEM_UI_FLAG_HIDE_NAVIGATION or
SYSTEM_UI_FLAG_FULLSCREEN or
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
} else {
SYSTEM_UI_FLAG_LAYOUT_STABLE
}
}
}
PinPモードに入ったときのレイアウト変更は、フルスクリーンモードでツールバーを隠すのみ。
Preview 公開当時のサンプルが多いので、今現在の最小限実装でやってみたメモ的な。
関連APIは変化している様子。
便利そうなのでました!
Android Developers Blog: Announcing new SDK versioning in Google Play services and Firebase
com.google.android.gms:play-services-*
com.google.firebase:firebase-*
に関しては、それぞれが独立したバージョンで記述してよい。
なので、以下のような「バージョンをを揃える」記述は不要。
buildscript {
ext {
play_version = '15.0.0'
}
}
dependencies {
// DON'T DO THIS!!
// The following use of the above buildscript property is no longer valid.
implementation "com.google.android.gms:play-services-auth:${play_version}"
implementation "com.google.firebase:firebase-auth:${play_version}"
implementation "com.google.firebase:firebase-firestore:${play_version}"
}
利用方法は以下2パターン。
classpath 'com.google.gms:google-services:3.3.0'
// 最終行
apply plugin: 'com.google.gms.google-services'
かまたは、
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.0'
// 最終行
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'
とのこと。
エラー。
ビルドできず。
The library com.google.android.gms:play-services-measurement-base
is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]],
but resolves to 15.0.2. Disable the plugin and check your dependencies tree
using ./gradlew :app:dependencies.
記述にはない「play-services-measurement-base」が
内部的に呼ばれてこけている。
メッセージに書いてある
./gradlew :app:dependencies
は実行すらできない。
それぞれは、Andrid Studioの自動チェックで最新のはずなのだが。

目視でGoogleリポジトリを確認。


AndroidStudioの自動チェックで最新版の「15.0.0」だと思っていたが
実は、古いバージョンのままだった。
実際は「15.0.2」が最新。

これに書き換えたらいけた。
しかし、AndroidStudioの自動最新バージョンチェック機能らしきは、
機能してなくね?
かまたは、微妙に古くね?
「Preference」-「Editor」-「Inspections」 にある
「Lint」-「Newer Library Versions Available」

OFFになってるが。
Description
Newer Library Versions Available This detector checks with a central repository to see if there are newer versions available for the dependencies used by this project. This is similar to the GradleDependency check, which checks for newer versions available in the Android SDK tools and libraries, but this works with any MavenCentral dependency, and connects to the library every time, which makes it more flexible but also much slower.
「毎回チェックするのでとろい」ということで
デフォルトでOFFになっているのか。
毎回でなく適時、意図的に実行したい場合は、
「Analyze」-「Run Inspection by Name」からいきましょう。

グレーのハイライトと同時にツールチップで最新版である
「15.0.2」
をサジェストしてくれました!
IntelliJ IDEAベースのIDEで使えるプラグインです。
なので、Android Studioでも使えます。
こういうかんじに括弧に色が付きます。



最近は、言語進化の影響か、
そういえば、多重に入れ子になった括弧を
使うことが多くなったような気もしますね。
👉 Rainbow Brackets - IntelliJ IDEs Plugin | Marketplace
👉 【AndroidStudio】プラグイン Rainbow Brackets が括弧だけでなく 変数 まで色が付くようになる【IDEA】
つづいて、インデントも色付けしますか。
見てますかYouTube。
おもしろいですね。
グループやともだちとLINEしながら見ると
もっと楽しそうです。
Android 7.0以上 では、画面下部ナビゲーションバーの右のボタン長押しで画面分割できます。

しかしLINEアプリは画面分割に対応してなかったりします。

「設定」-「端末情報」から「ビルド番号」を7回タップして「開発向けオプション」を有効化させてから、LINEでも画面分割ができるようにしてみましょう。

「設定」-「システム」-「開発向けオプション」から
「アクティビティをサイズ変更可能にする」

そのあと、電源ボタンで再起動します。

これでいけますね。

画面の比率が変更できない場合は、
「設定」-「ディスプレイ」-「表示サイズ」 で。


Android 9 Pie 使ってみた
【Android Pie】ナビゲーションバー の ホームボタン を ピル型 にする方法
【Android Pie】Google Digital Wellbeing を使う
【Android Pie】Auto-rotate (自動回転) OFF のときの挙動
【Android Pie】使いやすくなった音量設定
【Android Pie】スクリーンショット取得→編集 は「電源ボタン長押し」から