Android Tutorial Multiple instances of the same widget

corwin42

Expert
Licensed User
Longtime User
Has the issue of the disappearing widgets been fixed?

You are talking about the issue with the disappearing images in ImageViews in a widget?
This is an issue with the internal handling of bitmaps for RemoteViews in Android and has nothing to do with the subject of this tutorial. Please open a new thread for this issue.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User

I really hate splitting 1 topic up into a hundred threads. Makes it harder for everyone to keep track of it (especially the people who need to keep track of it, ie: you). It should all be in one, organized, easy to find place.

Especially since if/when you solve the issue (you said you were working on a library?) every single person who uses this code will need it. Not just me.
 

corwin42

Expert
Licensed User
Longtime User
This thread is about "multiple instances of a widget with different data".

The problem you have is not related to this subject. So if we merge several problems in one thread it all will get a mess and nobody will ever find the information. So it is better to have one thread for one issue.

For info: I have reported your problem in the past:Problem with widget with many /large images
 
Last edited:

NeoTechni

Well-Known Member
Licensed User
Longtime User
But the issue only happens when using this tutorial.
I didnt have it when i used only one widget type.

So if we merge several problems in one thread it all will get a mess and nobody will ever find the information

I feel no one will find it if you split it up. The solution would be updated into the first post
 

corwin42

Expert
Licensed User
Longtime User
But the issue only happens when using this tutorial.
I didnt have it when i used only one widget type.

Ok then it may look like it is related to the tutorial but trust me, it is not. I had this issue with "normal" widgets, too.

I fixed it for my project with a small library but this fix works because I use static images (drawables) from the resource directory. A general solution with generated images would be more complicated. The trick will be to save the bitmap to a file and give the ImageView of the widget a URI to the file and not the bitmap directly. It is even more complicated because the launcher needs to have access rights to the file you save. I will see if I can create an example.

Edit: And another small problem is that the solution will only work with Android SDK >= 8
 
Last edited:

Laurent95

Active Member
Licensed User
Longtime User
Sorry, it took some time.
Hello,

Thank you for do it, that works fine. And no worries it seems that i was busy also, then forgive me for late reply

I think if I add a nice application Icon it could be released to the market without change.

Lolllll indeed, and never i will do it, i respect your work. Even if i try to animate an imageview inside a widget, and take a weather/clock widget (who is really inspired from your work), for the example

Best regards.
 

Ionut Indigo

Member
Licensed User
Longtime User
Hi corwin42, I'm trying to compile the application and i get:
B4X:
res\xml\advancedwidget_info.xml:3: error: No resource identifier found for attribute 'minResizeWidth' in package 'android'
res\xml\advancedwidget_info.xml:3: error: No resource identifier found for attribute 'previewImage' in package 'android'
res\xml\advancedwidget_info.xml:3: error: No resource identifier found for attribute 'resizeMode' in package 'android'
res\xml\advancedwidget_info.xml:3: error: No resource identifier found for attribute 'widgetCategory' in package 'android'
Libraries AHLocale, RandomAccesFile and Reflection are checked.
What is there to do?
Thanks!
 

Laurent95

Active Member
Licensed User
Longtime User
Hi all
Just for you know how the work of Corwin is good, and of course some other guys who are very good also in coding
Take a look at this application :
https://play.google.com/store/apps/details?id=lizaprod.b4a.widget.easyclockweather&hl=en,
that i have does in starting from this tutorial in the first time. At this time, there are soon 17 000 installations since November 1st 2013.

I would thank you Markus for this very good tutorial about widgets and the usage of reflection library from Andrew Graham.
Respect for your work.

Regards.
 

Laurent95

Active Member
Licensed User
Longtime User
Laurent95,
good work!!!
The data, are stored in the database or in the preferences ?
Thank

Hello,
Thank you for the appreciation.
On this widget the data are stored in a file in the cache folder of application.
I don't stored all of the weather data, due to multiple instances of the widget possible.
That's the library who is called for the forecast and the weather data.
For the preferences it's the module called "StateManager v1.15" who manage all.
And Indeed as NeoTechni said, you can store it where you want, the module is clear and easy to understand.

Regards
 

Mrjoey

Active Member
Licensed User
Longtime User
Hello , is it possible to use statelistdrawable buttons and panels with background image? thanks.
 

leitor79

Active Member
Licensed User
Longtime User
Hi!

Thank you very much for sharing this! Very useful!

I'm wondering where the preview|thumbnail for the widget add is taken. I mean (the right one):


I've edited/remove all advancedwidget_layout_X.xml files from the layout and layout-land folders, but I still see the same box (my layouts doesn't even have a time control). Tried cleaning project (ctrl+p), deleting cache & data before uninstalling the app, with no luck.

Thank you very much!
 

corwin42

Expert
Licensed User
Longtime User
Sorry for the late answer.

The preview is a png file found in Objects\res\drawable

It can be configured in the Objects\res\xml\advancedwidget_info.xml
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…