https://kotlinlang.org logo
Title
c

Colton Idle

01/15/2023, 5:52 PM
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

Kimon

01/15/2023, 5:55 PM
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

Colton Idle

01/15/2023, 6:07 PM
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

Kimon

01/15/2023, 6:08 PM
c

Colton Idle

01/15/2023, 6:09 PM
The video i saw was definitely like ~3 years ago so I don't think it was glance specific?
m

Marcel Pinto

01/15/2023, 8:17 PM
It's not possible to drag and drop into the home screen. You need to use the pinning API mentioned above.
e

ephemient

01/16/2023, 1:45 AM
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

andrew

02/01/2023, 5:36 AM
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

Colton Idle

02/01/2023, 5:42 AM
interesting. the more i learn about widgets/shortcuts the less i know about em. lol