Scenario 1:
- Device is loaded
- I add first widget
- OneX -> Calls onEnabled | Galaxy Tab -> doesnt call onEnabled.
Scenario 2:
- Device is booted with widget already on screen.
- OneX -> Calls onEnabled | Galaxy Tab -> Calls onEnabled
But It must be called when user places one on screen (scenario 1), else whats the point. Surely you dont have to restart your device to get onEnabled called.
Its important, because I Attach a alarm manager to update my widget every 2 seconds:
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 1);
alarmManager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(), 1000, createClockTickIntent(context));
There is a similar question with no working solution: AppWidgetProvider: not called onEnabled method
There is no need to register these intents, and doing so doesnt help anyway.
My question is why is onEnabled not invoking, and how do I get it to.
It says on google Docs: ACTION_APPWIDGET_ENABLED:
Sent when an instance of an AppWidget is added to a host for the first time. This broadcast is sent at boot time if there is a AppWidgetHost installed with an instance for this provider.
Basically confirming that it should work in both scenarios
This is the intent that triggers onEnabled()
Called in response to the ACTION_APPWIDGET_ENABLED broadcast when the a AppWidget for this provider is instantiated. Override this method to implement your own AppWidget functionality.
The fact it works on the phone, and not the tablet, is strange. Is it an issue with android 3.2 and is there a work around?