Skip to content

Instantly share code, notes, and snippets.

@kasem-sm
Created May 30, 2022
Embed
What would you like to do?
Registering Glance widget in your Android Manifest file.
<application>
<receiver
<!-- Specify the package location of your widget receiver -->
android:name="your.package.DailyReadWidgetReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider" />
</receiver>
</applicaton>
// In your main/res/layout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name" />
</FrameLayout>
// In your main/res/xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="36dp"
android:minHeight="36dp"
android:resizeMode="horizontal|vertical"
android:minResizeWidth="36dp"
android:minResizeHeight="36dp"
android:initialLayout="@layout/widget_initial_layout"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment