androidkotlinandroid-widgetglance-appwidgetglance

Glance actionStartActivity not opening activity


This is the content of my widget:

@Composable
    private fun MyContent(glanceModifier: GlanceModifier = GlanceModifier, widgetData: WidgetData) {
        InfoPanel(
            glanceModifier = glanceModifier
                .padding(top = 2.dp)
                .fillMaxSize()
                .background(imageProvider = ImageProvider(R.drawable.widget_background))
                .appWidgetBackground()
                .clickable {
                    actionStartActivity<MainActivity>()
                },
            widgetData = widgetData
        )
    }

When I click on it, instead of opening the activity, this is printed on the logcat:

2025-05-14 13:08:03.791 1181-1687 EGL_emulation
com...le.android.apps.nexuslauncher D app_time_stats: avg=3761.89ms min=3761.89ms max=3761.89ms count=1

2025-05-14 13:08:03.794 416-693 audioserver
audioserver D logFgsApiBegin: FGS Logger Transaction failed, -129

2025-05-14 13:08:03.794 601-911 AS.PlaybackActivityMon system_server W No piid assigned for invalid/internal port id 15

2025-05-14 13:08:03.799 416-548 AudioFlinger
audioserver D mixer(0x7789f5d7f8e0) throttle end: throttle time(36)

Any idea why? I'm using last glance 1.1.1


Solution

  • Finally I discovered the problem, it was simply that I was using clickable{ } instead of clickable( ) and the first one didn't work with actionStartActivity but the second one did.