private static void setWidget(SimplePanel simple, WidgetProvider provider) {
   simple.clear();
   simple.add(provider.getWidget());
 }
  public void onConfirm(View source) {
    // Log that onConfirm was called
    Log.d(LOG, "WidgetConfigureActivity.onConfirm called.");

    // Set up the widget's preferences
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editPreferences = preferences.edit();
    // set our WIDGET_CONFIGURED_VALUE variable
    editPreferences.putBoolean(WidgetProvider.WIDGET_CONFIGURED_VALUE + "_" + widgetId, true);
    // commit the preferences
    editPreferences.commit();

    // Call for the widgets' first update
    Log.d(LOG, "WidgetConfigureActivity.onConfirm - Preparing first onUpdate broadcast.");

    // Setup for creating our onUpdate broadcast
    final Context context = WidgetConfigureActivity.this;

    // Create and package our broadcast
    Intent firstUpdate = new Intent(context, WidgetProvider.class);
    firstUpdate.setAction("android.appwidget.action.APPWIDGET_UPDATE");
    firstUpdate.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);

    // Send our first onUpdate broadcast
    context.sendBroadcast(firstUpdate);
    Log.d(LOG, "WidgetConfigureActivity.onConfirm - Sent first onUpdate broadcast.");

    // Create and launch the alarmManager
    Uri.Builder uriBuilder = new Uri.Builder();
    uriBuilder.appendPath("" + widgetId);
    Uri uri = uriBuilder.build();

    // Create our alarmUpdate Intent
    Intent alarmUpdate = new Intent(context, WidgetProvider.class);
    // Set an action so we can filter it
    alarmUpdate.setAction(WidgetProvider.UPDATE_ONE);
    // add the instance to identify it later
    alarmUpdate.setData(uri);

    // Add the widget's identifiers to the HashMap list
    WidgetProvider.addUri(widgetId, uri);

    alarmUpdate.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);

    // create the alarm info
    PendingIntent pendingAlarmUpdate =
        PendingIntent.getBroadcast(
            WidgetConfigureActivity.this, 0, alarmUpdate, PendingIntent.FLAG_UPDATE_CURRENT);

    // Create Alarm
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmManager.setRepeating(
        AlarmManager.RTC,
        System.currentTimeMillis() + ((updateFrequencyMins * 60) * 1000),
        ((updateFrequencyMins * 60) * 1000),
        pendingAlarmUpdate);

    // Log that onConfirm was called
    Log.d(LOG, "WidgetConfigureActivity.onConfirm - Created alarm.");
    Log.d(
        LOG,
        "WidgetConfigureActivity.onConfirm - ACTION: "
            + WidgetProvider.UPDATE_ONE
            + ", URI: "
            + uriBuilder.build().toString()
            + ", Minutes: "
            + updateFrequencyMins);

    // Return the original widgetId, found in onCreate()
    Intent resultValue = new Intent();
    resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    setResult(RESULT_OK, resultValue);
    finish();
  }