android-jetpack-composeandroid-appwidgetglance

Glance widget does not pop up when holding on the app launcher


The glance widget does not pop up when holding on the app icon, though the receiver is registered.

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:description="@string/widget_description"
    android:minWidth="400dp"
    android:minHeight="400dp"
    android:initialLayout="@layout/widget_initial_layout"
    android:previewImage="@string/app_name"
    android:resizeMode="vertical"
    />

Solution

  • The minWidth/Height defines the minimum available size the widget needs in order to be displayed. That means that if the device width or height is less than 400dp your widget cannot be displayed. Thus the launcher does not even show it in the list.

    Unless, you specify the android:minResizableWidth/Height and android:resizeMode="horizontal|vertical". If that value is less than the device size, the launcher will automatically resize it to fit.