title: How to make a widget work on the click of a button?
body: <p>My Midget works perfectly when i drag and drop it on my desktop. However, I want to perform my widget's action from my <code>TestActivity</code>'s Interface as well, on button click.</p>
  
  <p>Here is my <strong>Widget's receiver</strong>-</p>
  
  <pre><code>    package com.droideilhan.ultrasimpletaskkiller;
      public class USTaskKillerWidget extends AppWidgetProvider {
      public static String ACTION_WIDGET_RECEIVER = "ActionReceiverUltraSimpleTaskKillerWidget";
  
      @Override
      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
  
          RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
  
          Intent clicSurBtnKillIntent = new Intent(context, USTaskKillerWidget.class);
          clicSurBtnKillIntent.setAction(ACTION_WIDGET_RECEIVER);
          PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, clicSurBtnKillIntent, 0);
          remoteViews.setOnClickPendingIntent(R.id.btnKill, actionPendingIntent);
  
          appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
      }
  
      @Override
      public void onReceive(Context context, Intent intent) {
          // v1.5 fix that doesn't call onDelete Action
          final String action = intent.getAction();
          if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
              final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
              if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
                  this.onDeleted(context, new int[] { appWidgetId });
              }
          } else {
              // On a cliquÃ© sur le bouton
              if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)) {
  
                  // Liste des packages Ã  ne pas tuer.
                  List&lt;String&gt; reservedPackages = new ArrayList&lt;String&gt;();
                  reservedPackages.add("system");
                  reservedPackages.add("com.android.launcher2");
                  reservedPackages.add("com.android.inputmethod.latin");
                  reservedPackages.add("com.android.phone");
                  reservedPackages.add("com.android.wallpaper");
                  reservedPackages.add("com.google.process.gapps");
                  reservedPackages.add("android.process.acore");
                  reservedPackages.add("android.process.media");
  
                  // On tue tous les processus, sauf ceux de la liste
                  int compteProcessusTues = 0;
                  ActivityManager am = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE);
                  List&lt;RunningAppProcessInfo&gt; listeProcessus = am.getRunningAppProcesses();
                  for(RunningAppProcessInfo processus : listeProcessus) {           
                      //Log.d("TKTKTK", "========="+processus.pid+" : "+processus.processName);
                      String packageName = processus.processName.split(":")[0];
                      if (!context.getPackageName().equals(packageName) &amp;&amp; !reservedPackages.contains(packageName)) {
                          am.restartPackage(packageName);
                          compteProcessusTues++;
                      }
                  }
                  // Auto-kill (dÃ©sactivÃ© dans le cas d'un widget)
                  //am.restartPackage(context.getPackageName());
  
  
              }
              super.onReceive(context, intent);
          }
      }
  }
  </code></pre>
  
  <p><strong>Manifest</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.droideilhan.ultrasimpletaskkiller"
      android:versionCode="2"
      android:versionName="1.1" &gt;
  
      &lt;uses-sdk android:minSdkVersion="9" /&gt;
  
      &lt;application
          android:icon="@drawable/icon"
          android:label="Google Search" &gt;
          &lt;receiver
              android:name=".USTaskKillerWidget"
              android:label="Google Search" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt;
                  &lt;action android:name="com.droideilhan.android.widget.buttons.ButtonWidget.ACTION_WIDGET_RECEIVER" /&gt;
              &lt;/intent-filter&gt;
  
              &lt;meta-data
                  android:name="android.appwidget.provider"
                  android:resource="@xml/ustk_widget_provider" /&gt;
          &lt;/receiver&gt;
  
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/title_activity_main" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
      &lt;uses-permission android:name="android.permission.RESTART_PACKAGES" &gt;
      &lt;/uses-permission&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>Problem-</strong> Widgets's action never gets called, no force closes, no errors.</p>
  
  <p>Here is the button in my <strong>TestActivity</strong> (well this is what i have tried so far)</p>
  
  <pre><code>public void test(View view) {
      Intent intent = new Intent();
      intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
      sendBroadcast(intent);
      intent.setAction("com.droideilhan.android.widget.buttons.ButtonWidget.ACTION_WIDGET_RECEIVER");
      sendBroadcast(intent);
  }
  </code></pre>