Created
February 11, 2026 19:58
-
-
Save LethalMaus/9b4e0c88a9c54e1f4fb1b8e47827b3f9 to your computer and use it in GitHub Desktop.
WearOSComplication.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
| class QuickstartComplicationService: ComplicationDataSourceService() { | |
| override fun onComplicationRequest( | |
| request: ComplicationRequest, | |
| listener: ComplicationRequestListener | |
| ) { | |
| listener.onComplicationData(getComplicationData()) | |
| } | |
| override fun getPreviewData(type: ComplicationType): ComplicationData? { | |
| return getComplicationData() | |
| } | |
| private fun getComplicationData(): ComplicationData { | |
| val icon = Icon.createWithResource(this, R.mipmap.app_icon_round) | |
| val appName = getString(R.string.app_name) | |
| val launchIntent = packageManager.getLaunchIntentForPackage(packageName) | |
| val pendingIntent = PendingIntent.getActivity( | |
| this, | |
| 0, | |
| launchIntent, | |
| PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE | |
| ) | |
| return SmallImageComplicationData | |
| .Builder( | |
| SmallImage.Builder( | |
| icon, | |
| SmallImageType.ICON | |
| ).build(), | |
| PlainComplicationText.Builder(appName).build() | |
| ) | |
| .setTapAction(pendingIntent) | |
| .build() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment