title: listview in app widget android
body: <p>hi friends <a href="https://github.com/alchemisthq/appwidget-listview" rel="nofollow">enter link description here</a></p>
  
  <p>this link to create list view widget for my app, but here i want to add a button below the list view ,which on click will open my app,
  using the below code to acheive this,because it worked for me on other app, but not with  this example, how to do that .</p>
  
  <p>class widgetprovider</p>
  
  <pre><code>public class WidgetProvider extends AppWidgetProvider {
  
      // String to be sent on Broadcast as soon as Data is Fetched
      // should be included on WidgetProvider manifest intent action
      // to be recognized by this WidgetProvider to receive broadcast
      public static final String DATA_FETCHED = "com.wordpress.laaptu.DATA_FETCHED";
  
  
      /*
       * this method is called every 30 mins as specified on widgetinfo.xml this
       * method is also called on every phone reboot from this method nothing is
       * updated right now but instead RetmoteFetchService class is called this
       * service will fetch data,and send broadcast to WidgetProvider this
       * broadcast will be received by WidgetProvider onReceive which in turn
       * updates the widget
       */
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager,
              int[] appWidgetIds) {
  
          // which layout to show on widget
          RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
                  R.layout.widget_layout);
          Intent informationIntent = new Intent(context,info.class);
          PendingIntent infoPendingIntent = PendingIntent.getActivity(context,0, informationIntent, 0);
          remoteViews.setOnClickPendingIntent(R.id.btnSeeMore,infoPendingIntent);
  
          final int N = appWidgetIds.length;
          for (int i = 0; i &lt; N; i++) {
              Intent serviceIntent = new Intent(context, RemoteFetchService.class);
              serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                      appWidgetIds[i]);
              context.startService(serviceIntent);
          }
          super.onUpdate(context, appWidgetManager, appWidgetIds);
      }
  </code></pre>
  
  <p>manifest added a activity</p>
  
  <pre><code>&lt;activity android:name=".info" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.INFO" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  </code></pre>
  
  <p>when on click it should open my app,how to do that please help, thank you</p>
  
  <p>finaly i solved what i want to get,
  just wrote a button click code onReceive &amp; it worked</p>
  
  <pre><code>@Override
      public void onReceive(Context context, Intent intent) {
          super.onReceive(context, intent);
          if (intent.getAction().equals(DATA_FETCHED)) {
              Log.i("inside action", "DATA_FETCHED");
              int appWidgetId = intent.getIntExtra(
                      AppWidgetManager.EXTRA_APPWIDGET_ID,
                      AppWidgetManager.INVALID_APPWIDGET_ID);
              AppWidgetManager appWidgetManager = AppWidgetManager
                      .getInstance(context);
              RemoteViews remoteViews = updateWidgetListView(context, appWidgetId);
  
                Intent informationIntent = new Intent(context,MainActivity.class);
                PendingIntent infoPendingIntent = PendingIntent.getActivity(context,0, informationIntent, 0);
                remoteViews.setOnClickPendingIntent(R.id.txtSeeMore,infoPendingIntent);
  
              appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
          }   
  
  }
  </code></pre>