File tree Expand file tree Collapse file tree 8 files changed +69
-7
lines changed
android/views/notifications
example/snippet/views/appwidget Expand file tree Collapse file tree 8 files changed +69
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ plugins {
1818}
1919
2020android {
21- namespace = " com.example.example.snippet .views"
21+ namespace = " com.example.android .views"
2222 compileSdk = 35
2323
2424 defaultConfig {
@@ -48,6 +48,8 @@ android {
4848
4949dependencies {
5050
51+ implementation(" androidx.core:core:1.13.1" )
52+ implementation(" androidx.appcompat:appcompat:1.6.1" )
5153 implementation(libs.androidx.core.ktx)
5254 implementation(libs.androidx.appcompat)
5355 implementation(libs.google.android.material)
Original file line number Diff line number Diff line change 1515 limitations under the License.
1616-->
1717<manifest xmlns : android =" http://schemas.android.com/apk/res/android" >
18-
18+ <application >
19+ <activity android : name =" .notifications.NotificationSnippets$MainActivity"
20+ android : exported =" true" >
21+ <intent-filter >
22+ <action android : name =" android.intent.action.MAIN" />
23+ <category android : name =" android.intent.category.LAUNCHER" />
24+ </intent-filter >
25+ </activity >
26+ </application >
1927</manifest >
Original file line number Diff line number Diff line change 1+ package com .example .android .views .notifications ;
2+
3+ import android .app .Activity ;
4+ import android .os .Bundle ;
5+ import androidx .core .app .NotificationCompat ;
6+ import com .example .android .views .R ;
7+
8+ public class NotificationSnippets {
9+ private static final String CHANNEL_ID = "channel_id" ;
10+ private static final String textTitle = "Notification Title" ;
11+ private static final String textContent = "Notification Content" ;
12+
13+ public static class MainActivity extends Activity {
14+ @ Override
15+ protected void onCreate (Bundle savedInstanceState ) {
16+ super .onCreate (savedInstanceState );
17+ // [START android_views_notifications_build_basic]
18+ NotificationCompat .Builder builder = new NotificationCompat .Builder (this , CHANNEL_ID )
19+ .setSmallIcon (R .drawable .notification_icon )
20+ .setContentTitle (textTitle )
21+ .setContentText (textContent )
22+ .setPriority (NotificationCompat .PRIORITY_DEFAULT );
23+ // [END android_views_notifications_build_basic]
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import android.widget.RemoteViews
2525import androidx.glance.GlanceId
2626import androidx.glance.appwidget.GlanceAppWidget
2727import androidx.glance.appwidget.compose
28- import com.example.example.snippet .views.R
28+ import com.example.android .views.R
2929
3030class ExampleAppWidget : GlanceAppWidget () {
3131 override suspend fun provideGlance (context : Context , id : GlanceId ) {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import androidx.core.view.ViewCompat
2525import androidx.core.view.WindowInsetsCompat
2626import androidx.core.view.insets.GradientProtection
2727import androidx.core.view.insets.ProtectionLayout
28- import com.example.example.snippet .views.R
28+ import com.example.android .views.R
2929
3030class SystemBarProtectionSnippet : AppCompatActivity () {
3131
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <!--
3+ Copyright 2025 The Android Open Source Project
4+
5+ Licensed under the Apache License, Version 2.0 (the "License");
6+ you may not use this file except in compliance with the License.
7+ You may obtain a copy of the License at
8+
9+ https://www.apache.org/licenses/LICENSE-2.0
10+
11+ Unless required by applicable law or agreed to in writing, software
12+ distributed under the License is distributed on an "AS IS" BASIS,
13+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ See the License for the specific language governing permissions and
15+ limitations under the License.
16+ -->
17+ <shape xmlns : android =" http://schemas.android.com/apk/res/android"
18+ android : shape =" rectangle" >
19+ <solid android : color =" #FF0000" />
20+ <size android : width =" 24dp"
21+ android : height =" 24dp" />
22+ </shape >
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ plugins {
2222 application
2323}
2424
25+ kotlin {
26+ jvmToolchain(17 )
27+ }
28+
2529application {
2630 mainClass.set(" com.example.validator.Main" )
2731}
Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ android {
1616 versionName = " 1.0"
1717 }
1818 compileOptions {
19- sourceCompatibility = JavaVersion .VERSION_11
20- targetCompatibility = JavaVersion .VERSION_11
19+ sourceCompatibility = JavaVersion .VERSION_17
20+ targetCompatibility = JavaVersion .VERSION_17
2121 }
2222 kotlin {
23- jvmToolchain(11 )
23+ jvmToolchain(17 )
2424 }
2525 buildFeatures {
2626 compose = true
You can’t perform that action at this time.
0 commit comments