Skip to content

Instantly share code, notes, and snippets.

@waliahimanshu
Created November 17, 2020 21:37
Show Gist options
  • Save waliahimanshu/6e95695477dfdba345dd9ff021f7e452 to your computer and use it in GitHub Desktop.
Save waliahimanshu/6e95695477dfdba345dd9ff021f7e452 to your computer and use it in GitHub Desktop.
class WidgetUpdateNotifierImpl : WidgetUpdateNotifier {
override fun refreshWidget(context: Context) {
val intent = Intent(context, YourWidgetClassName::class.java)
intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
val componentName = ComponentName(context, YourWidgetClassName::class.java)
val ids: IntArray = AppWidgetManager.getInstance(context).getAppWidgetIds(componentName)
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
context.sendBroadcast(intent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment