I have simple widget for showing forecast and I am trying to update it after my request to the API I use is done. But I get this freaky error : "E/Finsky: [1] com.google.android.finsky.widget.a.onReceive(146): Refusing to update all widgets; need to narrow scope"
private void updateWidgets(Context context){
Intent updateIntent = new Intent();
updateIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
context.sendBroadcast(updateIntent);
}
I have tried to call this method in the activity, in the end of the service, or in a broadcast receiver(listening for broadcast from the service after its finished). Could anyone give me a suggestion what could I do wrong?
Widget class:
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for(int i = 0; i<appWidgetIds.length; i++){
int currentWidgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.weathy_widget_info);
//Some other unrelated stuff
appWidgetManager.updateAppWidget(currentWidgetId,views);
}
}
The method triggers the update, but it wont update the widget, and I dont know what is the problem. Also will it be possible to be something with working with SQLite in the onUpdate()?