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; /*ww w . ja va 2 s .c o m*/ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class TimeSyncNetworkReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { disable(context); TimeSyncService.networkBack(context); } } static void enable(Context context) { ReceiverUtils.enable(context, TimeSyncNetworkReceiver.class); } static void disable(Context context) { ReceiverUtils.disable(context, TimeSyncNetworkReceiver.class); } }