Example usage for android.content Intent ACTION_DATE_CHANGED

List of usage examples for android.content Intent ACTION_DATE_CHANGED

Introduction

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

Prototype

String ACTION_DATE_CHANGED

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

Click Source Link

Document

Broadcast Action: The date has changed.

Usage

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. c o 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.  j a v a2 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;

}