Hi to all ! I have a widget which becomes not clickable when screen orientation changes. After a lot of research on the net, I see that this problem occurs when the submitted RemoteViews is partially updated.
Problem is, I always fully update my RemoteViews. In fact, I have only 1 call to AppWidgetManager.updateAppWidget in my whole application, and it's in the AppWidgetProvider.onUpdate() method. As I posted its code at the end of the message, you can see that each RemoteViews sent contains a "on click pending intent", but I seems to disappear when the widget is re-created after screen orientation changes. As the onUpdate method is not called on this event, I cannot send a new RemoteViews with this Intent. I tried to call onUpdate from the onReceive method, which worked. Still, I don't like this dirty solution as I cannot filter on the action intended when triggering onReceive, because there is no action such as "on screen orientation changes", and I end up calling onUpdate on each received notification :s Could anyone please help me on this one ? Thanks in advance ! As promised, my onUpdate() method : @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); // Mise à jour de l'image dans les widgets updateClockinImage(context,appWidgetIds, getCheckingCount(context)); // Build the intent to call the service final Intent intent = new Intent(context.getApplicationContext(), AddCheckingService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); // Pour réagir à un clic il faut utiliser une pending intent car le onClickListener // est exécuté par l'application Home final PendingIntent pendingIntent = PendingIntent.getService(context.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.btn_checkin, pendingIntent); // Mise à jour des widgets avec le nouvel intent appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); super.onUpdate(context, appWidgetManager, appWidgetIds); } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en