change image widget

Post your questions and help other users.

Moderator: Martin

Post Reply
Drago73
Posts: 5
Joined: 24 Mar 2015 20:10

change image widget

Post by Drago73 » 30 Mar 2015 19:31

Hi
I want change an image for widget in event, how can i do?
Thanks

Drago73
Posts: 5
Joined: 24 Mar 2015 20:10

Re: change image widget

Post by Drago73 » 31 Mar 2015 07:19

Is a limitation change an image to widget?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: change image widget

Post by Martin » 01 Apr 2015 18:10

Hi,

You can use action Script with function setWidgetElementProperty to change an image from a flow.
A function call could look like this: setWidgetElementProperty("Widget1", "Image Element 1", "path", "/storage/emulated/0/image.jpg");

"Widget1" is the name of the widget
"Image Element 1" is the name of the image element on the widget
"path" is the name of the property to change
the last argument is the path to the image to use

Please use the button Function to create the function call so Automagic offers a dialog to pick the widget name, element name and property to change using a dialog.
I highly recommend to give the widget and the widget element a good name before you write a script to modify the widget.

Regards,
Martin

Drago73
Posts: 5
Joined: 24 Mar 2015 20:10

Re: change image widget

Post by Drago73 » 02 Apr 2015 16:11

Ok work fine!

User avatar
GollyJer
Posts: 15
Joined: 19 Sep 2016 01:01

Re: change image widget

Post by GollyJer » 13 Aug 2017 01:49

Hi. Sorry to dig up an old post... but is this still expected to work?
Does the launcher in use have an affect? I'm using Nova Launcher and am unable to update the widget icon.

The following does nothing.

Code: Select all

setWidgetElementProperty("Toggle Overlays", "Image_1", "path", "/storage/emulated/0/!ROM/4 - Tweaks/icons/off.png");
refreshWidget("Toggle Overlays",true);

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: change image widget

Post by Desmanto » 13 Aug 2017 04:45

I am using nova as well. When you created the widget, there is a prompt, you should allow it. Try to readd you widget to home screen.

I tried exactly as your script and copy a png to that path. Create a kind of toggle switch between 2 images, and it works. The image changed. Tried to execute the script alone, image still changed.

I know it can be done, but this is still a cool idea. Haven't explore the power of widget so far.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
GollyJer
Posts: 15
Joined: 19 Sep 2016 01:01

Re: change image widget

Post by GollyJer » 13 Aug 2017 15:04

Thanks for verifying Desmanto!
I deleted and readded the widget to my homescreen and now it's working as expected. Yeah! :!:

Post Reply