Hi
Hi
Can someone please tell me how can I use LL.create image method to create image from URI rather than the actual path. Is it possible? Else please share the alternative approach.
]]>
< ![CDATA[
Have you tried Uri.getPath() ?
]]>
< ![CDATA[
And if the Uri is not a path, you will have to copy the data to a file first, using the ContentResolver.
LL.getContext().getContentResolver().openInputStream()
Still, this will not work for all URIs, but the ones that can be handled by the platform for known content providers.
]]>
< ![CDATA[
Hmmm. Uri is not the path. Its in the format android.resource//packagename/drawable/icon_name
]]>
< ![CDATA[
Then you can use this call to directly load the image:
public Image LL.createImage (packagename, icon_name)
http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/LL.html#createImage(java.lang.String, java.lang.String)
]]>
< ![CDATA[
Pierre Hébert thanks mate. Will this work for icons from mipmap folder too or we have to use icon resource id instead?
]]>
< ![CDATA[
Not sure, LL looks for resource identifiers in the “drawable” category. I don’t know whether mimaps are translated into drawable at build time.
]]>
< ![CDATA[
Pierre Hébert Thanks for you help. Let me try it out and get back to you.
And Thanks to Lukas Morawietz for your suggestion.
]]>
< ![CDATA[
Pierre Hébert I tried passing package name, and icon name but with no luck. Its returning only the default android icon without any error. What are the changes if we pass the imageuri into the imageview, get Bitmap from it. Will it be possible to create LL Image from Bitmap. Otherwise i have to go with the OpenInputStreamMethod.
]]>
< ![CDATA[
Strange, if the image cannot be found in resources, it simply returns null. You can find a sample use of this API here: http://www.pierrox.net/android/applications/lightning_launcher/apk_script/Sketch-1.0.tar.gz , maybe it can help to troubleshoot what’s wrong.
I believe that if you see the Android icon then the problem could be elsewhere: it is displayed when the launcher cannot read the items icon. So maybe it is read correctly from the package resources, but not written correctly over the item’s one.
]]>
< ![CDATA[
Pierre Hébert Thanks. That worked. My apologies. It was my mistake. Instead of setDefaultIcon, i used setImage.
]]>
< ![CDATA[
great 🙂
]]>