I'm trying to google how to add a widget from WITH...
# glance
c
I'm trying to google how to add a widget from WITHIN an app. Like... in my compose activity I'm configuring something that then I want to drag out from the app onto my home screen. Is that something that's doable with widgets? Or am I mis-remembering things? I essentially want to place a widget on the screen, but be able to edit certain features about the widget and then have them reflect in the widget.
k
Widget pinning is an option, but I’m not sure if you can customize it first 🤔 https://developer.android.com/develop/ui/views/appwidgets/configuration#pin
c
I swear i saw a google io video a while back where you could dynamically generate things in your app and have users drag from your app onto the home screen. but i will look at that. thank you!
k
c
The video i saw was definitely like ~3 years ago so I don't think it was glance specific?
m
It's not possible to drag and drop into the home screen. You need to use the pinning API mentioned above.
e
for what it's worth, the UI presented on `requestPinAppWidget`/`requestPinShortcut` depends on the launcher, and it's certainly possible that allows the user to drag-and-drop it. but that's not under your control
a
Yeah, was about to echo, the launcher has specific permission to create and host a widget. An app can host one with permission, but it can't be dragged to the home screen
c
interesting. the more i learn about widgets/shortcuts the less i know about em. lol