Wyślij dane z aplikacji do Widget

Utknąłem w określonym scenariuszu. Muszę zaktualizować widżet, gdy tylko użytkownik zaktualizuje czas z aplikacji. Próbowałem Broadcast, wysyłając dane przez Intent Extras, ale tego nie robię. Obecnie mam swoje dane w AppWidgetProvider i muszę wysłać te dane do serwisu

public class CountdownWidget extends AppWidgetProvider {// SharedPreferences userDefaults;

// update rate in milliseconds
public static final int UPDATE_RATE = 1800000; // 30 minute

public static String nameOne = "";

@Override
public void onDeleted(Context context, int[] appWidgetIds) {
    for (int appWidgetId : appWidgetIds) {
        setAlarm(context, appWidgetId, -1);
    }
    super.onDeleted(context, appWidgetIds);
}

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub

    Bundle extras = intent.getExtras();
    nameOne = extras.getString("NAME_ONE");

    Log.e("Name: ", nameOne);

    super.onReceive(context, intent);
}

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
        int[] appWidgetIds) {

    for (int appWidgetId : appWidgetIds) {
        setAlarm(context, appWidgetId, UPDATE_RATE);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}

public static void setAlarm(Context context, int appWidgetId, int updateRate) {

    // Log.e("", "Updating Widget Service");

    PendingIntent newPending = makeControlPendingIntent(context,
            CountdownService.UPDATE, appWidgetId);
    AlarmManager alarms = (AlarmManager) context
            .getSystemService(Context.ALARM_SERVICE);
    if (updateRate >= 0) {
        alarms.setRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime(), updateRate, newPending);
    } else {
        // on a negative updateRate stop the refreshing
        alarms.cancel(newPending);
    }
}

public static PendingIntent makeControlPendingIntent(Context context,
        String command, int appWidgetId) {
    Intent active = new Intent(context, CountdownService.class);
    active.setAction(command);
    active.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    // this Uri data is to make the PendingIntent unique, so it wont be
    // updated by FLAG_UPDATE_CURRENT
    // so if there are multiple widget instances they wont override each
    // other
    Uri data = Uri.withAppendedPath(
            Uri.parse("countdownwidget://widget/id/#" + command
                    + appWidgetId), String.valueOf(appWidgetId));
    active.setData(data);
    return (PendingIntent.getService(context, 0, active,
            PendingIntent.FLAG_UPDATE_CURRENT));
}

}

Jak widzicienameOne jest zmienną statyczną. Mogę odbierać dane na stronieonReceive metoda używająca getExtras, ale nie jestem w stanie przekazać tych danych do mojegoCountdownService Usługa.

próbowałemCountdownWidget.nameOne ale nadal nie radzi sobie z danymi w usłudze.

Jakakolwiek pomoc będzie doceniona.

questionAnswers(2)

yourAnswerToTheQuestion