Slide 14
Slide 14 text
3. Add App Widget Provider
class SampleAppWidgetProvider : HomeWidgetProvider() {
override fun onUpdate(context: Context, appWidgetManager:
AppWidgetManager, appWidgetIds: IntArray, widgetData:
SharedPreferences) {
appWidgetIds.forEach { widgetId ->
val views = RemoteViews(context.packageName,
R.layout.sample_widget_layout).apply {
var srcText = widgetData.getString("_srcText",
"");
setTextViewText(R.id.srcText, srcText)
}
appWidgetManager.updateAppWidget(widgetId, views)
}
}
}
/: SampleAppWidgetProvider.kt