Back to project page timesync.
The source code is released under:
Apache License
If you think the Android project timesync listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package me.tatarka.timesync.lib; //from w w w. j a v a 2 s . co m import android.content.Context; import android.content.Intent; import android.support.v4.content.WakefulBroadcastReceiver; public class TimeSyncPowerReceiver extends WakefulBroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { boolean connected = false; if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) { connected = true; } else if (intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)) { connected = false; } startWakefulService(context, TimeSyncService.getPowerChangedIntent(context, connected)); } static void enable(Context context) { ReceiverUtils.enable(context, TimeSyncPowerReceiver.class); } static void disable(Context context) { ReceiverUtils.disable(context, TimeSyncPowerReceiver.class); } }