prefs.java
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
setResult(RESULT_OK, resultValue);
Context context = getApplicationContext();
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
Intent configIntent = new Intent(context, Prefs.class);
configIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, configIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.callbackwidget, pendingIntent);
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, views);
widget.xml
Problem is when i add widget IT IS NOT CLICKABLE. after rebooting phone it is working ok. also after deploying new build version, widget IS CLICKABLE
any ideas?
It might be that you have a config screen setup for your widget. If so then the widget is NOT built for you the first time it is added. Hard to tell from the code provided.
see http://developer.android.com/guide/topics/appwidgets/index.html. Specifically this sentence
great. problem was on NOT SENDING ACTION_APPWIDGET_UPDATE. so before closing preferences i send broadcast:
and in onreceive method of widget i check for broadcast
now it works like a charm ;)