I\'ve been working on a widget and making some advances (I hope) but still can\'t get it to do what I want.
I have a configurator activity which works ok. When it cl
For Updating Your Home Screen widget on Touch You need to Register a custom broadcast receiver in Manifest and add it as action with widget as:
Step 1: Register Custom Receiver as:
Step 2: In Your Widget Class AddAction to layout as:
public void onReceive(Context paramContext, Intent paramIntent)
{
//Intent
String str = paramIntent.getAction();
if (paramIntent.getAction().equals(ACTION_WIDGET_RANDOM)) {
updateWidgetState(paramContext, str);
}
else
{
super.onReceive(paramContext, paramIntent);
}
}
STEP 3: In Your updateWidgetState add new action to Intent as:
rview = new RemoteViews(paramContext.getPackageName(), R.layout.widget_layoutmain);
Intent active = new Intent(paramContext, Randomnuberwidget.class);
active.setAction(ACTION_WIDGET_RANDOM);
PendingIntent actionPendingIntent = PendingIntent.getBroadcast(paramContext, 0, active, 0);
rview.setOnClickPendingIntent(R.id.ImageView_gps, actionPendingIntent);
Finally you can Download Working HomeWidget Example from HERE HomeWidgetRendomNumber Which Generating Random Number On Every Click.