Button Event on a Widget Android

Ok so I've tried almost everything that comes to my mind but this button on my widget doesn't responds at all when touched. I want to open another class and associated xml when the button is clicked but the event does not responds.. following is my onUpdate() code

  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
   final int N = appWidgetIds.length;

   for (int i = 0; i < N; i++) {
     int appWidgetId = appWidgetIds[i];

      Intent intent = new Intent(context, Launch.class);
      PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);



      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget1);
      views.setOnClickPendingIntent(R.id.button, pendingIntent);


    appWidgetManager.updateAppWidget(appWidgetId, views);
    }
  }

}

<receiver
android:name="com.example.widgetexample.ExampleAppWidgetProvider"
android:label="8-bit cloud widget 1" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

<meta-data android:name="android.appwidget.provider"
            android:resource="@xml/widget1_inf" />
</receiver>

The application runs successfully after the error that it stopped un expectedly.widget's adds to the screen but the button doesnt works..ps Im new to android.Thanks in advance

链接地址: http://www.djcxy.com/p/8936.html

上一篇: Delphi XE5 Firemonkey TStringGrid OnClick事件

下一篇: Android小部件上的按钮事件