I have an app widget displaying timers. Timers can be started, stopped or resumed.
On Android 8 timers don't tick sometimes (50/50). Some users complained about the issue on Android 7 but I'm not absolutely sure if it's the same issue. Everything works well on Nexus 5 with Android 6 installed. If scroll down list view (until chronometer is invisible) and scroll up - timer starts ticking. If I put one more Chronometer above ListView and start - the chronometer is ticking well
ActivitiesRemoteViewsFactory
public RemoteViews getViewAt(int position) {
...
RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), getItemLayoutId());
if (timeLog.getState() == TimeLog.TimeLogState.RUNNING) {
remoteViews.setChronometer(R.id.widget_timer,
SystemClock.elapsedRealtime() - (duration * 1000 + System.currentTimeMillis() - timeLog.getStartDate().getTime()), null, true);
} else {
long timerValue = SystemClock.elapsedRealtime() - duration * 1000;
remoteViews.setChronometer(R.id.widget_timer, timerValue, null, false);
}
return remoteViews;
Update is sent from AppWidgetProvider's onReceive method
public void onReceive(Context context, Intent intent) {
AppWidgetManager widgetManager = AppWidgetManager.getInstance(ctx);
...
widgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_activities_list);
}
TargetSDK is 25
UPDATE The issue is also reproduced in main app. Something is wrong with listView as it works well in RecyclerView. Added simple example reproducing the issue at https://github.com/zaplitny/WidgetIssue