Example usage for android.content Intent ACTION_TIME_CHANGED

List of usage examples for android.content Intent ACTION_TIME_CHANGED

Introduction

In this page you can find the example usage for android.content Intent ACTION_TIME_CHANGED.

Prototype

String ACTION_TIME_CHANGED

To view the source code for android.content Intent ACTION_TIME_CHANGED.

Click Source Link

Document

Broadcast Action: The time was set.

Usage

From source file:com.meiste.greg.ptw.WidgetProvider.java

@Override
public void onReceive(final Context context, final Intent intent) {
    if (intent.hasExtra(Intent.EXTRA_ALARM_COUNT)) {
        Util.log("WidgetProvider.onReceive: Widget alarm");
        new UpdateWidgetThread(context).start();
        setAlarm(context);//from  w  w w.  ja  va2 s. co m
    } else if (intent.getAction().equals(Intent.ACTION_TIME_CHANGED)) {
        Util.log("WidgetProvider.onReceive: Time change");
        setAlarm(context);
    } else if (intent.getAction().equals(PTW.INTENT_ACTION_SCHEDULE)) {
        Util.log("WidgetProvider.onReceive: Schedule Updated");

        final int[] appWidgetIds = getInstalledWidgets(context);
        if (appWidgetIds.length > 0) {
            /* Force full widget update */
            sRace = null;
            onUpdate(context, AppWidgetManager.getInstance(context), appWidgetIds);
        }
    } else if (intent.getAction().equals(PTW.INTENT_ACTION_ANSWERS)) {
        Util.log("WidgetProvider.onReceive: Answers submitted");
        final int[] appWidgetIds = getInstalledWidgets(context);
        if (appWidgetIds.length > 0) {
            new UpdateWidgetThread(context).start();
        }
    } else
        super.onReceive(context, intent);
}

From source file:com.android.launcher3.widget.DigitalAppWidgetProvider.java

@Override
public void onReceive(Context context, Intent intent) {
    mComtext = context;//from   www.j  a  v a 2 s .co  m
    String action = intent.getAction();
    Log.i("sai", "onReceive: " + action);

    super.onReceive(context, intent);

    if (ACTION_ON_QUARTER_HOUR.equals(action) || Intent.ACTION_DATE_CHANGED.equals(action)
            || Intent.ACTION_TIMEZONE_CHANGED.equals(action) || Intent.ACTION_TIME_CHANGED.equals(action)
            || Intent.ACTION_LOCALE_CHANGED.equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                float ratio = WidgetUtils.getScaleRatio(context, null, appWidgetId);
                // SPRD for bug421127 add am/pm for widget
                WidgetUtils.setTimeFormat(widget,
                        (int) context.getResources().getDimension(R.dimen.widget_label_font_size),
                        R.id.the_clock);
                WidgetUtils.setClockSize(context, widget, ratio);
                //refreshAlarm(context, widget);
                appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget);
            }
        }
        if (!ACTION_ON_QUARTER_HOUR.equals(action)) {
            cancelAlarmOnQuarterHour(context);
        }
        startAlarmOnQuarterHour(context);
    }
    // cg sai.pan begin
    else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                refreshBtStatus(context, widget);
                appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget);
            }
        }
    } else if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
        int wifiStatus = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
        Log.e("sai", "wifiStatus" + wifiStatus);
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                if (WifiManager.WIFI_STATE_ENABLED == wifiStatus
                        || WifiManager.WIFI_STATE_ENABLING == wifiStatus) {
                    widget.setImageViewResource(R.id.wifi, R.drawable.status_wifi_on);
                } else {
                    widget.setImageViewResource(R.id.wifi, R.drawable.status_wifi_off);
                }
                appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget);
            }
        }
    } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        if (appWidgetManager != null) {
            int[] appWidgetIds = appWidgetManager.getAppWidgetIds(getComponentName(context));
            for (int appWidgetId : appWidgetIds) {
                RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);
                refreshWifiStatus(context, widget);
            }
        }
    } else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
        if (isNetworkConnected(context)) {
            Log.e("sai", "isNetworkConnected true");
            requestLocation(context);
        } else {
            Log.e("sai", "isNetworkConnected false");
        }
    }
}

From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    String intentAction = intent.getAction();
    if (intentAction != null) {
        switch (intentAction) {
        case ACTION_PIN_TASK:
            // nothing special to do right now
            break;

        case ACTION_PINNED_TASK_START:
            updateNotifications(true, true, true);
            delayedCancelHeadsUpNotification();
            break;

        case ACTION_PINNED_TASK_DUE:
            updateNotifications(true, true, true);
            delayedCancelHeadsUpNotification();
            break;

        case ACTION_COMPLETE:
            if (intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) {
                resolveUndoAction(intent);
                break;
            }//from   w w w.  java  2  s  .  c  o  m
            resolveCompleteAction(intent);
            break;

        case ACTION_UNPIN:
            resolveUnpinAction(intent);
            break;

        case ACTION_DELAY_1D:
        case ACTION_DELAY_1H:
            resolveDelayAction(intent);
            break;

        case NotificationActionUtils.ACTION_UNDO:
        case NotificationActionUtils.ACTION_DESTRUCT:
        case NotificationActionUtils.ACTION_UNDO_TIMEOUT:
            resolveUndoAction(intent);
            break;

        case Intent.ACTION_BOOT_COMPLETED:
        case Intent.ACTION_REBOOT:
        case TaskNotificationHandler.ACTION_FASTBOOT:
            updateNotifications(true, false, false);
            break;

        case Intent.ACTION_DATE_CHANGED:
        case Intent.ACTION_TIME_CHANGED:
        case Intent.ACTION_TIMEZONE_CHANGED:
        case ACTION_NEXT_DAY:
            updateNextDayAlarm();
            updateNotifications(false, false, false);
            break;

        case ACTION_CANCEL_HEADUP_NOTIFICATION:
            updateNotifications(false, false, false);
            break;

        default:
            updateNotifications(false, false, false);
            break;
        }
    }

    // check if the service needs to kept alive
    if (mTasksToPin == null || mTasksToPin.isEmpty()) {
        this.stopSelf();
    }
    return Service.START_NOT_STICKY;

}

From source file:tw.idv.gasolin.pycontw2012.ui.ScheduleFragment.java

@Override
public void onResume() {
    super.onResume();

    // Since we build our views manually instead of using an adapter, we
    // need to manually requery every time launched.
    requery();/* www  . j a  va  2 s .c o  m*/

    getActivity().getContentResolver().registerContentObserver(CoscupContract.Sessions.CONTENT_URI, true,
            mSessionChangesObserver);

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mReceiver, filter, null, new Handler());
}

From source file:com.google.android.apps.iosched.ui.ScheduleFragment.java

@Override
public void onResume() {
    super.onResume();

    // Since we build our views manually instead of using an adapter, we
    // need to manually requery every time launched.
    requery();/*from  w w w  .j a  v a 2  s . c  o m*/

    getActivity().getContentResolver().registerContentObserver(ScheduleContract.Sessions.CONTENT_URI, true,
            mSessionChangesObserver);

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mReceiver, filter, null, new Handler());
}

From source file:com.google.android.apps.iosched2.ui.ScheduleFragment.java

@Override
public void onResume() {
    super.onResume();

    SetupHelper.loadCurrentSetup(getActivity());

    // Since we build our views manually instead of using an adapter, we
    // need to manually requery every time launched.
    requery();//from   w w  w  .ja v a 2  s.  c om

    getActivity().getContentResolver().registerContentObserver(ScheduleContract.Sessions.CONTENT_URI, true,
            mSessionChangesObserver);

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mReceiver, filter, null, new Handler());
}

From source file:com.android.calendar.alerts.AlertService.java

void processMessage(Message msg) {
    Bundle bundle = (Bundle) msg.obj;/*from  w  w  w .j ava  2s  .  co m*/

    // On reboot, update the notification bar with the contents of the
    // CalendarAlerts table.
    String action = bundle.getString("action");
    if (DEBUG) {
        Log.d(TAG, bundle.getLong(android.provider.CalendarContract.CalendarAlerts.ALARM_TIME) + " Action = "
                + action);
    }

    // Some OEMs had changed the provider's EVENT_REMINDER broadcast to their own event,
    // which broke our unbundled app's reminders.  So we added backup alarm scheduling to the
    // app, but we know we can turn it off if we ever receive the EVENT_REMINDER broadcast.
    boolean providerReminder = action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER);
    if (providerReminder) {
        if (sReceivedProviderReminderBroadcast == null) {
            sReceivedProviderReminderBroadcast = Utils.getSharedPreference(this, PROVIDER_REMINDER_PREF_KEY,
                    false);
        }

        if (!sReceivedProviderReminderBroadcast) {
            sReceivedProviderReminderBroadcast = true;
            Log.d(TAG, "Setting key " + PROVIDER_REMINDER_PREF_KEY + " to: true");
            Utils.setSharedPreference(this, PROVIDER_REMINDER_PREF_KEY, true);
        }
    }

    if (providerReminder || action.equals(Intent.ACTION_PROVIDER_CHANGED)
            || action.equals(android.provider.CalendarContract.ACTION_EVENT_REMINDER)
            || action.equals(AlertReceiver.EVENT_REMINDER_APP_ACTION)
            || action.equals(Intent.ACTION_LOCALE_CHANGED)) {

        // b/7652098: Add a delay after the provider-changed event before refreshing
        // notifications to help issue with the unbundled app installed on HTC having
        // stale notifications.
        if (action.equals(Intent.ACTION_PROVIDER_CHANGED)) {
            try {
                Thread.sleep(5000);
            } catch (Exception e) {
                // Ignore.
            }
        }

        updateAlertNotification(this);
    } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
        // The provider usually initiates this setting up of alarms on startup,
        // but there was a bug (b/7221716) where a race condition caused this step to be
        // skipped, resulting in missed alarms.  This is a stopgap to minimize this bug
        // for devices that don't have the provider fix, by initiating this a 2nd time here.
        // However, it would still theoretically be possible to hit the race condition
        // the 2nd time and still miss alarms.
        //
        // TODO: Remove this when the provider fix is rolled out everywhere.
        Intent intent = new Intent();
        intent.setClass(this, InitAlarmsService.class);
        startService(intent);
    } else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
        doTimeChanged();
    } else if (action.equals(AlertReceiver.ACTION_DISMISS_OLD_REMINDERS)) {
        dismissOldAlerts(this);
    } else {
        Log.w(TAG, "Invalid action: " + action);
    }

    // Schedule the alarm for the next upcoming reminder, if not done by the provider.
    if (sReceivedProviderReminderBroadcast == null || !sReceivedProviderReminderBroadcast) {
        Log.d(TAG, "Scheduling next alarm with AlarmScheduler. " + "sEventReminderReceived: "
                + sReceivedProviderReminderBroadcast);
        AlarmScheduler.scheduleNextAlarm(this);
    }
}