Android appWidgetProvider onEnabled is never called on a tablet

Scenario 1:

  • Device loaded
  • Add the first widget
  • OneX → Call onEnabled | Galaxy Tab -> does not call onEnabled.

Scenario 2:

  • The device boots with widgets already on the screen.
  • OneX → Call onEnabled | Galaxy tab -> Call onEnabled

But it should be called when the user places it on the screen (scenario 1), otherwise what point. Of course, you do not need to restart the device to call onEnabled.

This is important because I attach an 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 without a working solution: AppWidgetProvider: the onEnabled method is not called

, .

, onEnabled , .

Google : ACTION_APPWIDGET_ENABLED:

, AppWidget . , AppWidgetHost .

,

, onEnabled()

ACTION_APPWIDGET_ENABLED, AppWidget . AppWidget.

, , , . Android 3.2 ?

+3
2

, , .

, , , .

, , , , onEnabled AND onUpdate. , onEnabled, onUpdate, ( ). onEnabled , , onUpdate.

, , onEnabled, , .

+1

. (, onUpdate())

0

Source: https://habr.com/ru/post/1532071/


All Articles