Pierre Hébert could you check if there is a problem with setDefaultIcon and/or createImage?
Pierre Hébert could you check if there is a problem with setDefaultIcon and/or createImage? This line worked before (I think until last beta, but I’m not sure)
play.setDefaultIcon(Image.createImage(MY_PKG, “ic_play”));
(context is the multitool music widget setup)
]]>« Script to launch Tasker task not working on latest beta. Here’s my code – any suggestions? (Previous Post)
(Next Post) Multitool V2.9b7 »
< ![CDATA[
The following script works for me with the beta build:
var i = getEvent().getContainer().addShortcut(“a”,new Intent(),0,0);
i.setDefaultIcon(Image.createImage(getActiveScreen().getContext().getPackageName(),”icon”));
It is very similar, I tried with getEvent().getItem() too (I mean with an already existing item, not a newly created one)
But I brought some modifications to the Image.createImage(pkg, name) method recently, in order to improve support for 9 patch. Maybe there’s a border effect here, I can’t see what at the moment, maybe a security exception due to the fact the package is not the same. Which android version do you use?
]]>
< ![CDATA[
Seems to work with external packages too
]]>
< ![CDATA[
Could you check if createImage returns null or a correct image please ?
]]>
< ![CDATA[
Pierre Hébert it returns a bitmap image.
]]>
< ![CDATA[
Is ic_play a bitmap that can be saved to file (possibly using saveToFile)?
By the way I tried with the music widget recently and icons were ok
]]>
< ![CDATA[
ic_play is a png resource. How would I save an Image to a file?
]]>
< ![CDATA[
using ImageBitmap.saveToFile() but I see no reason why it would fail using a png. This could have been the case for a vector drawable.
If so, does setDefaultIcon() works if you use a blank image created with createImage(int width, int height) ? If doesn’t replace the robot icon then setDefaultIcon would be in cause
]]>
< ![CDATA[
OK, the image is definetly created correctly, as I can save it to a file, even from the setup script.
I am on Android 6.
It is really weird. I can set this icon with a script on any item but the one which the setup script created that should have this icon. Even other items created by the same script accept the icon. Just the item which should already have this default icon doesn’t work. (This is the same for all 3 icons)
]]>
< ![CDATA[
The behaviour just changed again after I rerun the setup. Now I cannot set the icon on any items created by the setup, but still on other items. I am lost.
]]>
< ![CDATA[
Pierre Hébert do you have a github account so I can open the sources for you?
]]>
< ![CDATA[
Yes, since a few minutes: https://github.com/pierrehebert/
]]>
< ![CDATA[
Pierre Hébert
https://github.com/F43nd1r/Multitool/invitations
The setup script is in the raw folder called music_setup.js, but if you need more context feel free to look around.
]]>
< ![CDATA[
Thanks, I’ll look at this
]]>
< ![CDATA[
I found the bug (in setDefaultIcon, fails to save the icon because the icon directory wasn’t created). Interestingly this is a very old one, I wonder how it managed to survive.
]]>