Android Open Source - timesync Receiver Utils






From Project

Back to project page timesync.

License

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.

Java Source Code

package me.tatarka.timesync.lib;
/*  w  ww. j a v a2 s  .  c o m*/
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;

import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
import static android.content.pm.PackageManager.DONT_KILL_APP;

class ReceiverUtils {
    static <T extends BroadcastReceiver> void enable(Context context, Class<T> receiverClass) {
        ComponentName receiver = new ComponentName(context, receiverClass);
        PackageManager pm = context.getPackageManager();
        pm.setComponentEnabledSetting(receiver, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
    }

    static <T extends BroadcastReceiver> void disable(Context context, Class<T> receiverClass) {
        ComponentName receiver = new ComponentName(context, receiverClass);
        PackageManager pm = context.getPackageManager();
        pm.setComponentEnabledSetting(receiver, COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
    }
}




Java Source Code List

me.tatarka.timesync.app.MainActivity.java
me.tatarka.timesync.app.MyApplication.java
me.tatarka.timesync.app.RandomSync.java
me.tatarka.timesync.lib.BooleanFormatException.java
me.tatarka.timesync.lib.EventCalculator.java
me.tatarka.timesync.lib.MathUtil.java
me.tatarka.timesync.lib.ReceiverUtils.java
me.tatarka.timesync.lib.SuperNotCalledException.java
me.tatarka.timesync.lib.TimeSyncBootReceiver.java
me.tatarka.timesync.lib.TimeSyncNetworkReceiver.java
me.tatarka.timesync.lib.TimeSyncParser.java
me.tatarka.timesync.lib.TimeSyncPowerReceiver.java
me.tatarka.timesync.lib.TimeSyncPreferences.java
me.tatarka.timesync.lib.TimeSyncProxy.java
me.tatarka.timesync.lib.TimeSyncService.java
me.tatarka.timesync.lib.TimeSync.java