/// <summary> /// Updates the widget display image based on the new state /// </summary> /// <param name="context">Context.</param> /// <param name="newState">New state.</param> private void UpdateWidgetDisplay(Context context, int newState) { var appWidgetManager = AppWidgetManager.GetInstance(context); var remoteViews = new RemoteViews(context.PackageName, Resource.Layout.initial_layout); Log.Debug(APP_NAME, "this.GetType().ToString(): {0}", this.GetType().ToString()); var thisWidget = new ComponentName(context, this.Class); Log.Debug(APP_NAME, thisWidget.FlattenToString()); Log.Debug(APP_NAME, "remoteViews: {0}", remoteViews.ToString()); int imgResource = Resource.Drawable.bluetooth_off; switch ((Android.Bluetooth.State)newState) { case Android.Bluetooth.State.Off: case Android.Bluetooth.State.TurningOn: { imgResource = Resource.Drawable.bluetooth_off; break; } case Android.Bluetooth.State.On: case Android.Bluetooth.State.TurningOff: { imgResource = Resource.Drawable.bluetooth_on; break; } default: { imgResource = Resource.Drawable.bluetooth_off; break; } } remoteViews.SetImageViewResource(Resource.Id.imgBluetooth, imgResource); appWidgetManager.UpdateAppWidget(thisWidget, remoteViews); }