Example usage for android.content Intent ACTION_TIMEZONE_CHANGED

List of usage examples for android.content Intent ACTION_TIMEZONE_CHANGED

Introduction

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

Prototype

String ACTION_TIMEZONE_CHANGED

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

Click Source Link

Document

Broadcast Action: The timezone has changed.

Usage

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

@Override
public void onReceive(Context context, Intent intent) {
    mComtext = context;//w w  w. j av  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  .  ja va2 s  . c  om*/
            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:net.gaast.giggity.ScheduleViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    app = (Giggity) getApplication();//w  w w . jav  a 2 s.c om

    pref = PreferenceManager.getDefaultSharedPreferences(app);
    curView = getResources()
            .getIdentifier(pref.getString("default_view", "net.gaast.giggity:id/block_schedule"), null, null);
    showHidden = pref.getBoolean("show_hidden", false);

    /* Consider making this a setting, some may find their tablet too small. */
    int screen = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
    tabletView = (screen >= Configuration.SCREENLAYOUT_SIZE_LARGE);

    setContentView(R.layout.schedule_view_activity);
    View dl = drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawer = (RelativeLayout) dl.findViewById(R.id.drawer);

    drawer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // NOOP at least for now just so touches don't fall through to bigScreen.
        }
    });

    ViewGroup menu = (LinearLayout) dl.findViewById(R.id.menu);
    menu.getChildCount();
    /* Set event handler for all static buttons, going to the option menu code. Dynamic buttons
     * (from the schedule) have their own handlers. */
    for (int i = 0; i < menu.getChildCount(); ++i) {
        View btn = menu.getChildAt(i);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Not for now as I can't undo it (toggler not calling handlers?) TODO v.setBackground(getResources().getDrawable(R.drawable.menu_gradient));
                onOptionsItemSelectedInt(v.getId());
                drawerLayout.closeDrawers();
            }
        });
    }

    if (wantDrawer) {
        /* Hamburger menu! */
        /* Should still consider v7-appcompat, depending on how much it, again, affects apk size.. */
        getActionBar().setDisplayHomeAsUpEnabled(true);
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_menu_white_24dp,
                R.string.navdrawer_on, R.string.navdrawer_off) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                invalidateOptionsMenu();
                /* Looks like this code doesn't actually run BTW. Need to figure that out later. */
                updateNavDrawer();
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                invalidateOptionsMenu();
            }
        };
    } else {
        drawerLayout.removeView(drawer);
    }

    bigScreen = (LinearLayout) dl.findViewById(R.id.bigScreen);
    updateOrientation(getResources().getConfiguration().orientation);

    viewerContainer = (RelativeLayout) dl.findViewById(R.id.viewerContainer);

    /* TODO: See if I can do this in XML as well? (It's a custom private view.) */
    RelativeLayout.LayoutParams lp;
    lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    days = new DayButtons(this);
    viewerContainer.addView(days, lp);

    redraw = false;
    timer = new Handler();

    /* If the OS informs us that the timezone changes, close this activity so the schedule
       gets reloaded. (This because input is usually TZ-unaware while our objects aren't.) */
    tzClose = new BroadcastReceiver() {
        @Override
        public void onReceive(Context arg0, Intent arg1) {
            ScheduleViewActivity.this.finish();
        }
    };
    registerReceiver(tzClose, new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED));

    if (!getIntent().getAction().equals(Intent.ACTION_VIEW))
        return;

    String url = getIntent().getDataString();
    Fetcher.Source fs;
    if (getIntent().getBooleanExtra("PREFER_CACHED", false))
        fs = Fetcher.Source.CACHE_ONLINE;
    else
        fs = Fetcher.Source.ONLINE_CACHE;

    /* I think reminders come in via this activity (instead of straight to itemview)
       because we may have to reload schedule data? */
    if (url.contains("#")) {
        String parts[] = url.split("#", 2);
        url = parts[0];
        showEventId = parts[1];
    }

    if (app.hasSchedule(url)) {
        try {
            sched = app.getSchedule(url, fs);
        } catch (Exception e) {
            // Java makes me tired.
            e.printStackTrace();
        }
        onScheduleLoaded();
    } else {
        loadScheduleAsync(url, fs);
    }
}

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();/*from  w  w w.  j av a  2 s . co  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();//ww  w. j  a  va 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.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.  j  a  v a2 s. co  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());
}