Created
April 21, 2017 12:54
-
-
Save pedrofelipemm/5545f1527ef86bc4cb8b204ada12820b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { | |
for (int appWidgetId : appWidgetIds) { | |
PendingIntent pendingIntent = TaskStackBuilder.create(context) | |
.addNextIntentWithParentStack(new Intent(context, MainActivity.class)) | |
.addNextIntent(new Intent(context, DetailActivity.class)) | |
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); | |
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_stocks); | |
views.setRemoteAdapter(R.id.widget_list, new Intent(context, StocksWidgetRemoteViewsService.class)); | |
views.setPendingIntentTemplate(R.id.widget_list, pendingIntent); | |
views.setEmptyView(R.id.widget_list, R.id.widget_empty); | |
appWidgetManager.updateAppWidget(appWidgetId, views); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment