package com.jqmobile.core.android.time.impl;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Toast;
public class TimeReceiver extends BroadcastReceiver {
private static final String ACTION_DATE_CHANGED = Intent.ACTION_DATE_CHANGED;
private static final String ACTION_TIME_CHANGED = Intent.ACTION_TIME_CHANGED;
private SharedPreferences sp;
Context context;
public void onReceive(Context context, Intent intent) {
this.context = context;
String action = intent.getAction();
sp = context.getSharedPreferences("SP", 0);
if (ACTION_DATE_CHANGED.equals(action)) {
zero();
Toast.makeText(context, "���ڸı�", Toast.LENGTH_SHORT).show();
}
if (ACTION_TIME_CHANGED.equals(action)) {
zero();
Toast.makeText(context, "ʱ��ı�", Toast.LENGTH_SHORT).show();
}
}
private void zero() {
sp.edit().putLong("localityTime", new Date().getTime()).commit();
sp.edit().putLong("time", new Function(context).getNetTime()).commit();
}
}