-
Notifications
You must be signed in to change notification settings - Fork 370
Additional notification code snippets migration #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alabiaga
wants to merge
4
commits into
android:main
Choose a base branch
from
alabiaga:notification_snippets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
compose/snippets/src/main/java/com/example/compose/snippets/notifications/ReplyReceiver.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright 2026 The Android Open Source Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.example.compose.snippets.notifications | ||
|
|
||
| import android.content.BroadcastReceiver | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.graphics.BitmapFactory | ||
| import android.net.Uri | ||
| import androidx.core.app.RemoteInput | ||
|
|
||
| // [START android_notification_reply_receiver] | ||
| class ReplyReceiver : BroadcastReceiver() { | ||
| override fun onReceive(context: Context, intent: Intent) { | ||
| val dataResults = RemoteInput.getDataResultsFromIntent(intent, KEY_REPLY) | ||
| val imageUri: Uri? = dataResults?.get("image/*") as? Uri | ||
|
|
||
| if (imageUri != null) { | ||
| // Extract the image | ||
| context.contentResolver.openInputStream(imageUri)?.use { inputStream -> | ||
| val bitmap = BitmapFactory.decodeStream(inputStream) | ||
| // Display the image | ||
| // ... | ||
| } | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| const val KEY_REPLY = "key_reply" | ||
| const val KEY_TEXT_REPLY = "key_text_reply" | ||
| } | ||
| } | ||
| // [END android_notification_reply_receiver] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- | ||
| Copyright 2026 The Android Open Source Project | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="20dp" | ||
| android:height="20dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M184,415.93Q171,402.86 171,383.93Q171,365 184.07,352Q197.14,339 216.07,339Q235,339 248,352.07Q261,365.14 261,384.07Q261,403 247.93,416Q234.86,429 215.93,429Q197,429 184,415.93ZM712,415.93Q699,402.86 699,383.93Q699,365 712.07,352Q725.14,339 744.07,339Q763,339 776,352.07Q789,365.14 789,384.07Q789,403 775.93,416Q762.86,429 743.93,429Q725,429 712,415.93ZM78,516L78,516L78,516L78,516L78,516L78,516L78,516Q78,516 78,516Q78,516 78,516ZM912,516L912,516L912,516L912,516Q912,516 912,516Q912,516 912,516L912,516L912,516L912,516L912,516ZM168,864L96,864L96,696L264,696Q204,696 162.5,654Q121,612 121,552L193,552Q193,581.7 213.5,602.85Q234,624 263.96,624L263.96,504L362,504L330,369Q309,281 239,224.5Q169,168 78,168L48,168L48,96L78,96Q192,96 281.5,165Q371,234 398,345L444,530Q449,547.48 438.22,561.74Q427.44,576 410,576L336,576L336,696Q336,725.7 314.85,746.85Q293.7,768 264,768L168,768L168,864ZM864,864L792,864L792,768L696,768Q666.3,768 645.15,746.85Q624,725.7 624,696L624,576L552,576Q534,576 523,561Q512,546 517,529L564,335Q592,232 678,164Q764,96 876,96L912,96L912,168L876,168Q791,168 722,221Q653,274 630,369L598,504L696.04,504L696.04,624Q726,624 747.09,602.85Q768.19,581.7 768.19,552L840,552Q840,612 798,654Q756,696 696,696L864,696L864,864ZM336,696L336,696L336,624L336,624L336,696ZM624,696L624,624L624,624L624,696Z"/> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- | ||
| Copyright 2026 The Android Open Source Project | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="20dp" | ||
| android:height="20dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960" | ||
| android:tint="?attr/colorControlNormal" | ||
| android:autoMirrored="true"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M744,750L744,606Q744,556 709,521Q674,486 624,486L282,486L405,609L354,660L144,450L354,240L405,291L282,414L624,414Q704,414 760,470Q816,526 816,606L816,750L744,750Z"/> | ||
| </vector> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.