https://kotlinlang.org logo
Join SlackCommunities
Powered by
# glance
  • i

    Ido Flax

    12/15/2023, 5:45 PM
    Hello. Android noob here. I’m developing an app using compose MP, that also has a widget in android using glance (didn’t get to the iOS widget part yet). I understand that glance provides it’s own composable UI functions like Row, Column etc, but is not using the equivalent compose functions of Row, Column etc. It also has it’s own Modifier and the function params are a bit different. My question is, is there a good way/pattern to share ui logic between my main app code and the widget? like if i want to reuse some components/ui logic between the two. So far i can’t find or think of a way to do it without copy/paste/tweak?
    👍 2
    a
    e
    • 3
    • 3
  • i

    Ido Flax

    12/28/2023, 12:25 AM
    So question #2: I have a widget that is showing a progress bar and a timer, showing how long left for something, meant to be on the lock screen eventually (think something like your taxi or delivery app showing how far away the driver is for example, though my case is simpler as it simply depends on the current time). Rest in the thread: -->
    s
    • 2
    • 2
  • h

    heec.choi

    01/03/2024, 10:04 AM
    Hello, i have a question about glance library. If you implement it with Glance, can't you separate the app widget provider process with android:process=":remote"? I have a question because there is an issue where the update does not occur when the process is separated.
    s
    • 2
    • 7
  • v

    Vinu Polly

    01/31/2024, 3:29 PM
    Hey there I'm pretty new to Glance and been just playing around with the docs but couldn't find much in terms of how to approach a particular problem I have. 1. How do I approach the problem of triggering a UI refresh based on a network call. What is the recommended approach for doing this? 2. If I have a continuously recomposing Glance widget (like progressbar), do I have to always send in updates? If so can this only be done via protoDataStore?
    c
    • 2
    • 3
  • j

    Jan Bína

    02/10/2024, 2:49 PM
    Hi, I have a question regarding using color resources in glance. In some cases, it is not possible (or I haven't found a way) to use a color resource - for example to set the color of Text, because color of
    TextStyle
    is of type
    ColorProvider
    and the factory function to create
    ColorProvider
    from resource is restricted to the library and says
    Returns a [ColorProvider] that resolves to the color resource. This should not be used outside of the Glance Libraries due to inconsistencies with regards to what process (app vs launcher) colors are resolved in
    That's also the case with
    colorFilter
    for
    Image
    , color of
    CircularProgressIndicator
    and probably more. On the other hand, there's a
    .background
    modifier that accepts color resource and is working just fine. I tried to overcome this by using
    RemoteViews
    directly, so for example I can set the color of Text like this:
    Copy code
    AndroidRemoteViews(
        remoteViews = RemoteViews(context.packageName, R.layout.widget_textview).apply {
            setTextViewText(R.id.text, text)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                setTextViewTextColorResource(R.id.text, colorRes)
            } else {
                setTextColor(R.id.text, LocalContext.current.getColor(colorRes))
            }
        },
    )
    and this seems to be working fine too. After all, the glance theme's dynamic colors are also created from resources... So, what's the reason for that restriction of
    ColorProvider
    ? And can my approach with remote views cause troubles in some cases (not resolving to correct color)?
    b
    w
    • 3
    • 2
  • m

    Md Sohail

    02/19/2024, 11:55 AM
    Is there any way to identify the widgets inside the receiver in the onEnabled function and also in the onDisable function? In the glance widget Thanks in advance!
  • b

    Birgit L

    03/15/2024, 3:16 PM
    Have you guys had success with using the
    glance-experimental-tools
    for getting a preview for your app widget? I've tried
    appwidget-host
    as well as
    appwidget-viewer
    but didn't have success with either method. Is this still the way to do glance previews or is there a newer method out there? My widget is done, so technically I don't need previews any more but I would have liked to use the preview image export.
    f
    • 2
    • 4
  • f

    Farhazul Mullick

    04/13/2024, 9:53 AM
    Anyone has idea why
    horizontalArrangement
    is not provided in
    compose.glance.layout.Row
    ?
  • f

    Farhazul Mullick

    04/13/2024, 4:56 PM
    How can we get same behaviour like
    Arrangement. SpaceBetween
  • t

    tony-choi

    04/17/2024, 9:37 AM
    Has anyone written a test code for the glance widget? Or is there a guide on this?
    b
    • 2
    • 1
  • h

    Hristijan

    04/25/2024, 11:58 AM
    hey guys, did anyone figure this out? I want to use the ImageVector from the compose’s material library in a widget, but the image provider doesn’t have an ability to do so https://stackoverflow.com/questions/77167962/how-to-use-an-imagevector-in-a-glance-widget
    b
    • 2
    • 1
  • h

    heec.choi

    04/29/2024, 5:36 AM
    Is there anyway to use AdapterViewFlipper in glance?
  • n

    Nthily

    04/29/2024, 2:24 PM
    Has anyone used Compose Glance? Its latest version (1.0.0) seems to always display the
    initialLayout
    and not show the custom interface i've written. also, I've tried upgrading other repos that use glance to i 1.0.0 and they all have this issue and include this: https://github.com/android/user-interface-samples/tree/main/AppWidget
  • r

    Rihards

    05/14/2024, 8:33 AM
    Hi! Is there a way I can set a widget preview depending on the dark mode? Or should I provide light / dark widgets to the user all the time, ignoring the mode. I use
    android:previewImage
    to display the preview.
    ✅ 1
    b
    • 2
    • 2
  • r

    Rihards

    05/17/2024, 8:09 AM
    Hi! I’m not able to trigger the
    doWork
    function for the
    CoroutineWorker
    to fetch data for the widget. Any idea of what could be the reason? 😕 I’m using very similar logic as in this sample, but it’s not working for me.
    ✅ 1
    • 1
    • 2
  • h

    Hristijan

    05/17/2024, 7:32 PM
    Hey guys, is there any library implementation that works to load images within Compose UI for glance?
  • r

    Rihards

    05/20/2024, 1:22 PM
    How should I handle
    androidx.glance.session.SessionWorker
    inside the
    WorkerFactory
    of
    CoroutineWorker
    ? I have to use the factory due to dependency injection, but now it seems quite confusing.
    ✅ 1
    • 1
    • 1
  • n

    Nizam

    05/24/2024, 8:53 AM
    I have a widget that's created using jetpack glance API. It stops working once I do an app update. Can someone please help here? I will post the relevant code in the thread below
    k
    w
    • 3
    • 11
  • n

    Nizam

    05/27/2024, 4:21 PM
    vivo Android 13 version crashing continuously
    c
    • 2
    • 3
  • o

    Osanosa

    07/27/2024, 4:51 PM
    What's supported minApi? Doesn't work on sdk22
  • o

    Osanosa

    07/27/2024, 5:12 PM
    Is it possible to add widget composable to Main Activity for preview?
  • n

    Nizam

    07/28/2024, 2:54 AM
    How to capture crashes happening in jetpack glance widget. we have integrated firebase but it's not getting logged. please help
    • 1
    • 1
  • l

    Lukáš Kúšik

    10/04/2024, 9:02 AM
    Is there a way to get the size measurement of the current Composable in Glance? Something like
    BoxWithConstraints
    or a hack with RemoteViews that would expose a measurement.
    n
    • 2
    • 3
  • l

    Lukáš Kúšik

    10/15/2024, 9:10 AM
    I have published a simple library that enables using any regular Composables inside Glance. https://github.com/cvb941/Deglance
    😍 5
    😲 1
  • m

    Mantas Varnagiris

    10/21/2024, 2:56 PM
    Hi, I've been struggling for a few days now and I just can't get to make the simplest thing work. What am I doing wrong? I have a simple widget with
    LazyColumn
    but it seems like it composes ALL items in the list regardless if they are visible or not. Effectively behaving like
    Column
    with scroll
    b
    • 2
    • 7
  • n

    Nizam

    10/22/2024, 12:31 PM
    sometimes when our users update the app, this weird white bubble comes. can someone help us fix this?
    • 1
    • 4
  • n

    Nathan79c

    04/10/2025, 5:23 PM
    Hi team, I need to be guided with glance. I'm creating an application that allows you to record your phrases that motivate me the most, but I think it's not interesting to have the application to read a phrase that motivates us and that we like, so I decided to use glance to create a widget that displays a quote from the list endlessly after 3 seconds, and so far in the docs I can't find something that suits me to do that. For the application to be ready, it's just the widget part with glance that's causing me problems, and I'm at point zero. Could someone have a solution?
    c
    • 2
    • 8
  • b

    bbade_

    04/28/2025, 5:49 PM
    set the channel topic: Jetpack Glance: https://developer.android.com/jetpack/androidx/releases/glance File bugs here: https://issuetracker.google.com/issues?q=status:open%20componentid:1097239
  • p

    Pablo

    05/12/2025, 1:07 PM
    Hi, maybe someone can help in this channel? Google recommends to use CoroutineWorker to update our new Glance widgets, I suposse that using a periodic work started in Application when the app is started for the first time, for example, because now, widgets doesn't have onEnabled() method, that in oldschool widgets was used to start periodic threads for updating them. So I see a problem here. If the user has not placed any widget on the desktop, why should we have to start a periodic worker constantly updating? Do google offers a solution for this? I don't find it.
    t
    c
    • 3
    • 4
  • p

    Pablo

    05/12/2025, 1:55 PM
    Also, related to Glance, it seems that it doesn't apply the colors of the theme, on their composables:
    Copy code
    provideContent {
        GlanceTheme(
            // Using colors from app theme
            colors = ColorProviders(light = lightScheme,dark = darkScheme)
        ) {
            MyContent()
        }
    }
    is ignoring primary and onPrimary, for example I need to do this to force white text in my texts:
    Copy code
    Text(style = TextStyle(color = GlanceTheme.colors.onPrimary))
    is this normal? to be mandatory to set manually every color of the theme in every composable used in glance?