Skip to content

Commit 75fbf5b

Browse files
Snippets for /training/wearables/apps/splash-screen (#692)
1 parent 43ac10f commit 75fbf5b

File tree

8 files changed

+179
-1
lines changed

8 files changed

+179
-1
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ coil = "2.7.0"
3939
compileSdk = "36"
4040
compose-latest = "1.9.4"
4141
composeUiTooling = "1.5.4"
42-
coreSplashscreen = "1.0.1"
42+
coreSplashscreen = "1.2.0"
4343
coroutines = "1.10.2"
4444
dataStore = "1.1.7"
4545
datastoreCore = "1.1.7"

wear/src/main/AndroidManifest.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@
2929
android:label="@string/app_name"
3030
android:supportsRtl="true"
3131
android:theme="@android:style/Theme.DeviceDefault">
32+
33+
<!-- [START android_wear_splash_manifest] -->
34+
<activity
35+
android:name=".snippets.SplashScreenActivity"
36+
android:exported="true"
37+
android:taskAffinity=""
38+
android:theme="@style/Theme.App.Starting">
39+
<!-- [START_EXCLUDE] -->
40+
<intent-filter>
41+
<action android:name="android.intent.action.MAIN" />
42+
43+
<category android:name="android.intent.category.LAUNCHER" />
44+
</intent-filter>
45+
<!-- [END_EXCLUDE] -->
46+
</activity>
47+
<!-- [END android_wear_splash_manifest] -->
48+
3249
<uses-library
3350
android:name="com.google.android.wearable"
3451
android:required="true" />
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.wear.snippets
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
23+
24+
// [START android_wear_splash_activity]
25+
class SplashScreenActivity : ComponentActivity() {
26+
override fun onCreate(savedInstanceState: Bundle?) {
27+
installSplashScreen()
28+
super.onCreate(savedInstanceState)
29+
30+
setContent {
31+
WearApp()
32+
}
33+
}
34+
}
35+
// [END android_wear_splash_activity]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<!-- [START android_wear_splash_drawable] -->
18+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
19+
<item
20+
android:width="@dimen/splash_screen_icon_size"
21+
android:height="@dimen/splash_screen_icon_size"
22+
android:drawable="@mipmap/ic_launcher"
23+
android:gravity="center" />
24+
</layer-list>
25+
<!-- [END android_wear_splash_drawable] -->
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<!-- [START android_wear_splash_dimens] -->
18+
<resources>
19+
<!-- Round app icon can take all of default space -->
20+
<dimen name="splash_screen_icon_size">48dp</dimen>
21+
</resources>
22+
<!-- [END android_wear_splash_dimens] -->
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
<!-- [START android_wear_splash_style] -->
18+
<resources>
19+
<style name="Theme.App" parent="@android:style/Theme.DeviceDefault" />
20+
21+
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
22+
<!-- Set the splash screen background to black -->
23+
<item name="windowSplashScreenBackground">@android:color/black</item>
24+
<!-- Use windowSplashScreenAnimatedIcon to add a drawable or an animated
25+
drawable. -->
26+
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
27+
<!-- Set the theme of the Activity that follows your splash screen. -->
28+
<item name="postSplashScreenTheme">@style/Theme.App</item>
29+
</style>
30+
</resources>
31+
<!-- [END android_wear_splash_style] -->
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<!-- [START android_wear_splash_dimens_other] -->
18+
<resources>
19+
<!-- Non-round icon with background must use reduced size to fit circle -->
20+
<dimen name="splash_screen_icon_size">36dp</dimen>
21+
</resources>
22+
<!-- [END android_wear_splash_dimens_other] -->
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
<resources>
18+
<style name="Theme.App" parent="@android:style/Theme.DeviceDefault" />
19+
20+
<!-- [START android_wear_splash_style_other] -->
21+
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
22+
<!-- Set a white background behind the splash screen icon. -->
23+
<item name="windowSplashScreenIconBackgroundColor">@android:color/white</item>
24+
</style>
25+
<!-- [END android_wear_splash_style_other] -->
26+
</resources>

0 commit comments

Comments
 (0)