title: Problems with widget in Android
body: <p>I'm trying to make a very simple widget there. It seems to be somehow unregistered WidgetProvider, because no debug messages come to my LogCat (I'm sure, log filter is right, and I tried adding Toast show), as well as no errors come out.</p>
  
  <p>I will be <strong>really glad</strong> of any help, because I spend few hours and tried few lessons...</p>
  
  <p>I have done everything by a lesson, but changed the names and classes. There are my classes:</p>
  
  <p>Provider:</p>
  
  <pre><code>public class WidgetProvider extends AppWidgetProvider {
  
  
  private static final String LOGIN_CLICKED = "com.example.intent.action.LOGIN_CLICKED";
  
  
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager,
          int[] appWidgetIds) {
  
      Log.d("my_log", "onUpdate");
  
      RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.activity_main);
      remoteViews.setOnClickPendingIntent(R.id.button_login, buildButtonPendingIntent(context, LOGIN_CLICKED));
  
      pushWidgetUpdate(context, remoteViews);
  }
  
  public static PendingIntent buildButtonPendingIntent(Context context, String action) {
      Log.d("my_log", "buildButtonPendingIntent");
  
      Intent intent = new Intent();
      intent.setAction(action);
      return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  }
  
  public static void pushWidgetUpdate(Context context, RemoteViews remoteViews) {
      ComponentName myWidget = new ComponentName(context, WidgetProvider.class);
      AppWidgetManager manager = AppWidgetManager.getInstance(context);
      manager.updateAppWidget(myWidget, remoteViews);     
  }
  
   }
  </code></pre>
  
  <p>Receiver:</p>
  
  <pre><code>public class WidgetReceiver extends BroadcastReceiver {
  
  private static final String LOGIN_CLICKED = "com.example.intent.action.LOGIN_CLICKED";
  
  @Override
  public void onReceive(Context context, Intent intent) {
      Log.d("my_log", "onRecieve");
  
      if(intent.getAction().equalsIgnoreCase(LOGIN_CLICKED)){
          makeLogin(context);
      }
  }
  
  private void makeLogin(Context context) {
  
      Log.d("my_log", "MakeLogin");
  
      RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.activity_main);
      //remoteViews.setImageViewResource(R.id.widget_image, getImageToSet());
  
      //REMEMBER TO ALWAYS REFRESH YOUR BUTTON CLICK LISTENERS!!!
      remoteViews.setOnClickPendingIntent(R.id.button_login, WidgetProvider.buildButtonPendingIntent(context, LOGIN_CLICKED));
  
      WidgetProvider.pushWidgetUpdate(context.getApplicationContext(), remoteViews);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My manifest:</p>
  
  <pre><code> &lt;application
      android:label="TwiWi Twitter Widget"&gt;
  
      &lt;receiver
          android:name="WidgetProvider"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt;
          &lt;/intent-filter&gt;
  
          &lt;meta-data
              android:name="android.appwidget.provider"
              android:resource="@xml/widget_provider" /&gt;
      &lt;/receiver&gt;
  
      &lt;receiver
          android:name="WidgetReceiver"
          android:label="widgetBroadcastReceiver"&gt;
  
          &lt;intent-filter&gt;
              &lt;action android:name="com.example.intent.action.LOGIN_CLICKED" /&gt;
          &lt;/intent-filter&gt;
  
          &lt;meta-data
              android:name="android.appwidget.provider"
              android:resource="@xml/widget_provider" /&gt;
  
      &lt;/receiver&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p>And my xml: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
      android:minWidth="294dip"
      android:minHeight="146dip"
      android:updatePeriodMillis="1000000"
      android:initialLayout="@layout/activity_main" &gt;
  
  
  &lt;/appwidget-provider&gt;
  </code></pre>
  
  <p>If you think I messed with layout or button name, there is my Layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:orientation="vertical"
          android:background="@android:color/white"
          android:layout_gravity="center"
          android:layout_height="wrap_content"&gt;
  
  &lt;TextView android:id="@+id/widget_textview"
                  android:text="Hello Widget"
                  android:layout_height="wrap_content"
                  android:layout_width="wrap_content"
                  android:layout_gravity="center_horizontal|center"
                  android:textColor="@android:color/black"/&gt;
  
  &lt;Button
      android:id="@+id/button_login"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal|center"
      android:text="Button" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>