title: programmatically added RemoteViews Button should open activity by clicking android
body: <p>I added a button programmatically to a LinearLayout and I want to make it clickable to open the activity:</p>
  <p>The Button is created like this:</p>
  <pre><code>RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.android_app_widget);
  RemoteViews media = new RemoteViews(context.getPackageName(), R.layout.button_layout);
  rv.addView(R.id.buttons_list, media);
  </code></pre>
  <p>how do I use the<code>setOnClickPendingIntent</code> to make the <strong>RemoteViews media</strong> clickable???</p>
  <p><a href="https://stackoverflow.com/questions/9266710/adding-textviews-to-home-screen-widget-programmatically/20040066">Adding TextViews to home screen widget programmatically</a></p>
  <p>this one just explain how to add a Button/View programmatically</p>
  <p>I tried to use something like this but I don't have any ID for the RemoteView because it is created programmatically...</p>
  <pre><code>remoteviews.setOnClickPendingIntent(R.id.**i don't have a id**,
              getPendingSelfIntent(context, OPEN_APP));
  
  
  protected PendingIntent getPendingSelfIntent(Context context, String action) {
      Intent intent = new Intent(context, getClass());
      intent.setAction(action);
      return PendingIntent.getBroadcast(context, 0, intent, 0);
  }
  </code></pre>