How to Make Picture-in-Picture Mode on Android With Code Examples

Switching to PIP mode

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {// Что-то связанное с PIP}
<"true" />
val isPipSupported = context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
override fun onUserLeaveHint() {...if (isPipSupported && imaginaryCallManager.isInCall)this.enterPictureInPictureMode()}

Interface adaptation

override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean,newConfig: Configuration?) {super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)setIsUiVisible(isInPictureInPictureMode)}


val endCallPendingIntent = getPendingIntent()val endCallAction = RemoteAction(// Иконка для кнопки; цвет будет проигнорирован и заменен на системныйIcon.createWithResource(this, R.drawable.ic_baseline_call_end_24),// Текст кнопки, который не будет показан"End call",// ContentDescription для screen readers"End call button",// Наш PendingIntent, который будет запущен при нажатии на кнопкуendCallPendingIntent)
val pipParams = PictureInPictureParams.Builder().setActions(listOf(endCallAction)).build()this.enterPictureInPictureMode(pipParams)


Other articles about calls on Android




Video and Multimedia Software Developmet company

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Flutter PlatformView: How to create Widgets from Native Views

How To Handle Configuration Changes in Android


Notifications in Flutter

Android 360 panorama

A better way to handle links in TextView

Substituting Android's LiveData: StateFlow or SharedFlow?

Creating A Fully Custom Checkbox in Android

Making REST calls in Kotlin Android using OKHTTP and Couroutines

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fora Soft

Fora Soft

Video and Multimedia Software Developmet company

More from Medium

Root Android device Pixel 6

Notes on Android Dev — Lecture 1 — Why/What/How Android

Android Loopers and Handlers Demystified

Data is Scrollable or not in WebView Android?