I would like to open another installed app by button/imageButton click from my app widget provider. Here is my code,
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int count = appWidgetIds.length;
for (int i = 0; i < count; i++) {
int widgetId = appWidgetIds[i];
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.activity_main);
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.imageViewBus, pendingIntent);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
}
}
Thanks in advance.