= AppWidgetManager.getInstance(context) val remoteViews = RemoteViews(context.getPackageName(), R.layout.widget_container) // ListItemʹߋ৽௨Λߦ͏ͨΊͷintentΛ࡞ val intent = Intent(context, SampleWidgetService::class.java) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId) remoteViews.setRemoteAdapter(R.id.widgetListView, intent) // ListItem͕ۭͩͬͨ߹ͷEmptyදࣔ remoteViews.setEmptyView(R.id.widgetListView, android.R.id.empty) // ListItemΛλοϓͨ͠ͱ͖ͷintentΛηοτ // ListItemͷଆͰηοτ͢ΔͷͰͳ͘ɺ͜͜Ͱηοτ͢Δ val onClickIntent = Intent(context, DetailActivity::class.java) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) val onClickPendingIntent = PendingIntent.getActivity(context, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT) remoteViews.setPendingIntentTemplate(R.id.widgetListView, onClickPendingIntent) manager.updateAppWidget(appWidgetId, remoteViews) }