close
Skip to content

Add snippets for Jetpack PiP and notifications#900

Open
alabiaga wants to merge 7 commits intoandroid:mainfrom
alabiaga:main
Open

Add snippets for Jetpack PiP and notifications#900
alabiaga wants to merge 7 commits intoandroid:mainfrom
alabiaga:main

Conversation

@alabiaga
Copy link
Copy Markdown
Member

@alabiaga alabiaga commented May 5, 2026

Add code snippets for Jetpack PiP library

Start migrating embedded non snippet code samples for notification documentation in developer.android.com

@alabiaga alabiaga requested review from a team, kkuan2011 and yrezgui as code owners May 5, 2026 19:06
@alabiaga alabiaga requested a review from raystatic May 5, 2026 19:06
@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented May 5, 2026

Here is the summary of changes.

You are about to add 3 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@alabiaga alabiaga requested a review from ashnohe May 5, 2026 19:06
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new code snippets for Android notifications and Picture-in-Picture (PiP) functionality, including the addition of the androidx.core.pip dependency. The feedback identifies several critical runtime issues, such as an invalid Intent constructor call and uninitialized lateinit properties in the new PiP activities. There are also suggestions to improve Kotlin idiomaticity by removing unnecessary semicolons and correcting descriptive comments.

alabiaga added 2 commits May 5, 2026 13:32
Change-Id: I39e13958f811889e70b72c6e71256da7c3e75e72
Change-Id: I4661f0db980c7fea5131c95101f9cefe147fd8ad
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.Bundle
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these new imports in this file needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, must've added this by mistake. removing

Comment thread compose/snippets/build.gradle.kts Outdated
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.core.pip)
implementation(libs.androidx.core.telecom)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the telecom dependency needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core.pip is but i don't know why telecom was pulled in. I'll remove

}
}

override fun onDestroy() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Compose, instead of overriding activity lifecycle methods, I believe we prefer to use DisposableEffect inside a composable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks Kat

private lateinit var pictureInPictureImpl: BasicPictureInPicture
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
pictureInPictureImpl = BasicPictureInPicture(this)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to clean up pictureInPictureImpl in this file too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did clean it up in both files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm can you tell me which line number it is in this file? maybe I'm not seeing it..

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i instantiate pictureInPictureImpl in line 32 vs inline on line 29 as suggested by the assistant

Change-Id: I2f1a9b5c2366c6d7bb416e146bebaa40f78fe414
private lateinit var pictureInPictureImpl: BasicPictureInPicture
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
pictureInPictureImpl = BasicPictureInPicture(this)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm can you tell me which line number it is in this file? maybe I'm not seeing it..

import androidx.compose.ui.platform.LocalContext
import androidx.core.app.PictureInPictureModeChangedInfo
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getMainExecutor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this import needed? I do see it used in the other files though

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing..it's strange that these are getting added, as I am not touching this file at all.

alabiaga added 2 commits May 5, 2026 16:52
Change-Id: I46f5785f220e884135395ae05246a2756de91848
Copy link
Copy Markdown
Member Author

@alabiaga alabiaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Kat

private lateinit var pictureInPictureImpl: BasicPictureInPicture
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
pictureInPictureImpl = BasicPictureInPicture(this)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i instantiate pictureInPictureImpl in line 32 vs inline on line 29 as suggested by the assistant

import androidx.compose.ui.platform.LocalContext
import androidx.core.app.PictureInPictureModeChangedInfo
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getMainExecutor
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing..it's strange that these are getting added, as I am not touching this file at all.

@alabiaga
Copy link
Copy Markdown
Member Author

alabiaga commented May 6, 2026

Checking in, let's discuss offline any open issues that aren't resolve and I'll follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants