标签:ant intent cti time gis tap receiver get vat
package com.android.demo.lileidemo.listener;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import com.android.demo.lileidemo.MyApplication;
import com.android.demo.lileidemo.constant.AppConstants;
/**
* date: 04/22/2020.
* author: lilei.
*/
public class DateTimeChangedReceiver extends BroadcastReceiver {
private static final String TAG = AppConstants.APP_TAG + "DateTimeChangedReceiver ";
private Handler mWorker;
private static volatile DateTimeChangedReceiver mInstance;
public DateTimeChangedReceiver() {
mWorker = new Handler();
}
/**
* get Instance.
*
* @return instance.
*/
public static DateTimeChangedReceiver getInstance() {
if (mInstance == null) {
synchronized (DateTimeChangedReceiver.class) {
if (mInstance == null) {
mInstance = new DateTimeChangedReceiver();
}
}
}
return mInstance;
}
public void registerIviStateChangeListener() {
//LogUtil.d(TAG + "registerIviStateChangeListener()");
registerReceiver();
}
/**
* registerReceiver.
*/
private void registerReceiver() {
//LogUtil.d(TAG + "registerReceiver private");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_TIME_CHANGED);
intentFilter.addAction(Intent.ACTION_DATE_CHANGED);
MyApplication.getAppContext().registerReceiver(DateTimeChangedReceiver.getInstance(),
intentFilter);
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null && (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())
|| Intent.ACTION_DATE_CHANGED.equals(intent.getAction()))) {
//LogUtil.d(TAG + "onReceive:" + intent.getAction());
doDateTimeChange();
}
}
private void doDateTimeChange() {
//when data time change should reInit timer.
//call reInitTimer();
}
}
标签:ant intent cti time gis tap receiver get vat
原文地址:https://www.cnblogs.com/adamli/p/13140575.html