Hello guys'n'girls :)
I'm slighty puzzled about how android's AppWidget machinery works.
I reimplemented the AppWidgetProvider's constructor like this:
public class MyProvider extends AppWidgetProvider {
public MyProvider() {
Log.d("TEST", "Creating...")
}
public void onUpdate(..., int[] appWidgetIds) {
// updating stuff here
}
}
From what I've read in the docs, I understood that AppWidgetProvider is instantiated once, when widget of that type is added for the first time. If another widget of the same type gets added, it will be managed by exactly that provider.
But I just discovered that this is not the case!
For each widget I add, android creates a new MyProvider (I see that from 'adb logcat' - it prints "Creating..." for each widget)! I don't understad why :) Maybe I got something wrong? Or documentation isn't clear on something. What's the reason of having appWidgetIds passed to onUpdate and other methods if each provider is managing only ONE widget?