Java Code Examples for android.content.Intent#ACTION_TIMEZONE_CHANGED

The following examples show how to use android.content.Intent#ACTION_TIMEZONE_CHANGED . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void registerReceiver() {
    if (mRegisteredReceiver) {
        return;
    }
    mRegisteredReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    filter.addAction(Intent.ACTION_LOCALE_CHANGED);
    DigitalWatchFaceService.this.registerReceiver(mReceiver, filter);
}
 
Example 2
Source Project: wearable   File: myWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    myWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 3
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 4
void setTimeZoneImpl(String tz) {
    if (TextUtils.isEmpty(tz)) {
        return;
    }

    TimeZone zone = TimeZone.getTimeZone(tz);
    // Prevent reentrant calls from stepping on each other when writing
    // the time zone property
    boolean timeZoneWasChanged = false;
    synchronized (this) {
        String current = SystemProperties.get(TIMEZONE_PROPERTY);
        if (current == null || !current.equals(zone.getID())) {
            if (localLOGV) {
                Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID());
            }
            timeZoneWasChanged = true;
            SystemProperties.set(TIMEZONE_PROPERTY, zone.getID());
        }

        // Update the kernel timezone information
        // Kernel tracks time offsets as 'minutes west of GMT'
        int gmtOffset = zone.getOffset(System.currentTimeMillis());
        setKernelTimezone(mNativeData, -(gmtOffset / 60000));
    }

    TimeZone.setDefault(null);

    if (timeZoneWasChanged) {
        Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED);
        intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
                | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND
                | Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
        intent.putExtra("time-zone", zone.getID());
        getContext().sendBroadcastAsUser(intent, UserHandle.ALL);
    }
}
 
Example 5
Source Project: wearable   File: MyTapFace.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyTapFace.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 6
Source Project: DevUtils   File: TimeReceiver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    try {
        String action = intent.getAction();
        // 打印当前触发的广播
        LogPrintUtils.dTag(TAG, "onReceive Action: " + action);
        // 判断类型
        switch (action) {
            case Intent.ACTION_TIMEZONE_CHANGED: // 时区改变
                if (sListener != null) {
                    sListener.onTimeZoneChanged();
                }
                break;
            case Intent.ACTION_TIME_CHANGED: // 设置时间
                if (sListener != null) {
                    sListener.onTimeChanged();
                }
                break;
            case Intent.ACTION_TIME_TICK: // 每分钟调用
                if (sListener != null) {
                    sListener.onTimeTick();
                }
                break;
        }
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "onReceive");
    }
}
 
Example 7
Source Project: wearable   File: beerWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    beerWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 8
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 9
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    ComplicationWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 10
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    ComplicationWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 11
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 12
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 13
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    ComplicationWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 14
Source Project: wearable   File: myWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    myWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 15
Source Project: AcDisplay   File: TimeView.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case Intent.ACTION_TIME_TICK:
        case Intent.ACTION_TIME_CHANGED:
        case Intent.ACTION_TIMEZONE_CHANGED:
            updateClock();
            break;
    }
}
 
Example 16
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 17
Source Project: watchface   File: MyWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 18
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    SunsetsWatchFace.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 19
Source Project: watchface   File: MyWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 20
Source Project: watchface   File: MyWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}