1+ /*
2+ * Copyright 2025 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.notifications
18+
19+ import android.content.Context
20+ import androidx.core.app.NotificationCompat
21+ import androidx.wear.phone.interactions.notifications.BridgingConfig
22+ import androidx.wear.phone.interactions.notifications.BridgingManager
23+
24+ private const val channelId = " 1"
25+
26+ fun setBridgeTags (context : Context ) {
27+ // [START android_wearcompanion_notification_bridge_tags]
28+ val notification = NotificationCompat .Builder (context, channelId)
29+ // ... set other fields ...
30+ .extend(
31+ NotificationCompat .WearableExtender ()
32+ .setBridgeTag(" tagOne" )
33+ )
34+ .build()
35+ // [END android_wearcompanion_notification_bridge_tags]
36+ }
37+
38+ fun disableBridging (context : Context ) {
39+ // [START android_wearcompanion_notification_disable_bridging]
40+ // In this example, bridging is only enabled for tagOne, tagTwo and tagThree.
41+ BridgingManager .fromContext(context).setConfig(
42+ BridgingConfig .Builder (context, isBridgingEnabled = false )
43+ .addExcludedTags(listOf (" tagOne" , " tagTwo" , " tagThree" ))
44+ .build()
45+ )
46+ // [END android_wearcompanion_notification_disable_bridging]
47+ }
48+
49+ fun setDismissalId (context : Context ) {
50+ // [START android_wearcompanion_notification_dismissal_id]
51+ val notification = NotificationCompat .Builder (context, channelId)
52+ // ... set other fields ...
53+ .extend(
54+ NotificationCompat .WearableExtender ()
55+ .setDismissalId(" abc123" )
56+ )
57+ .build()
58+ // [END android_wearcompanion_notification_dismissal_id]
59+ }
0 commit comments