I created an APP Widget with 3 buttons.
This section of code assigns the button functions:
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.activity_widget);
Intent intent_busca = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com.br"));
PendingIntent pending_busca = PendingIntent.getActivity(context, 0, intent_busca, 0);
Intent intent_exemplo = new Intent(context, ExemploActivity.class);
PendingIntent pending_exemplo = PendingIntent.getActivity(context, 0, intent_exemplo, 0);
Intent intent_stack = new Intent(Intent.ACTION_VIEW, Uri.parse("https://pt.stackoverflow.com"));
PendingIntent pending_stack = PendingIntent.getActivity(context, 0, intent_stack, 0);
views.setOnClickPendingIntent(R.id.widget_busca_btn, pending_busca);
views.setOnClickPendingIntent(R.id.widget_exemplo_btn, exemplo_scan);
views.setOnClickPendingIntent(R.id.widget_stack_btn, pending_stack);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
However, I wanted to make a change to my intents
. Before each such action I wanted to first direct my user to MainActivity
.
Click > MainActivity > Functionality clicked.