Java Code Examples for android.content.IntentFilter

The following examples show how to use android.content.IntentFilter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void onReceive(Context context, Intent intent) {
    // Save usage statistics right now!
    // We need to use the statics at this moment
    // for "skipping foreground apps"
    // No app is foreground after the screen is locked.
    mScreenLockTime = new Date().getTime();
    if (SettingsManager.getInstance().getSkipForegroundEnabled() &&
            Utility.checkUsageStatsPermission(FreezeService.this)) {
        UsageStatsManager usm = getSystemService(UsageStatsManager.class);
        mUsageStats = usm.queryAndAggregateUsageStats(mScreenLockTime - APP_INACTIVE_TIMEOUT, mScreenLockTime);
    }

    // Delay the work so that it can be canceled if the screen
    // gets unlocked before the delay passes
    mHandler.postDelayed(mFreezeWork,
            ((long) SettingsManager.getInstance().getAutoFreezeDelay()) * 1000);
    registerReceiver(mUnlockReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
}
 
Example 2
@Override
protected void onResume() {
    super.onResume();
    Log_OC.e(TAG, "onResume() start");

    // refresh list of files
    refreshListOfFilesFragment();

    // Listen for sync messages
    IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
    syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
    syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
    mSyncBroadcastReceiver = new SyncBroadcastReceiver();
    registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);

    Log_OC.d(TAG, "onResume() end");
}
 
Example 3
Source Project: PresencePublisher   Source File: BatteryMessageProvider.java    License: MIT License 6 votes vote down vote up
@Override
protected List<String> getMessageContents() {
    if (!getSharedPreferences().getBoolean(SEND_BATTERY_MESSAGE, false)) {
        HyperLog.d(TAG, "Battery messages disabled, not generating any messages");
        return Collections.emptyList();
    }

    HyperLog.i(TAG, "Scheduling battery message");
    IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent batteryStatus = getApplicationContext().registerReceiver(null, filter);

    if (batteryStatus == null) {
        HyperLog.w(TAG, "No battery status received, unable to generate message");
        return Collections.emptyList();
    }

    int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

    int batteryPct = (int) (level / (0.01f * scale));

    return Collections.singletonList(Integer.toString(batteryPct));
}
 
Example 4
Source Project: zen4android   Source File: ZenNotificationActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	try {
		
		IntentFilter filter = new IntentFilter();
		filter.addAction(ZenNotificationModel.ZEN_NEW_NOTIFICATION);
		filter.addAction(ZenNotificationModel.ZEN_NOTIFICATION_EMPTY);
		filter.addAction(ZenNotificationModel.ZEN_LOAD_NOTIFICATION_FAILED);
		registerReceiver(mBroadcastReceiver, filter);
		
		if (ZenUtils.getToken() != null) {
			// loged in
			mLoadingView.show();
			model.load();
		}
		refresh();
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 5
/**
 * To be called from an Activity or Fragment's onResume method.
 */
public void onResume() {
    Session session = Session.getActiveSession();
    if (session != null) {
        if (callback != null) {
            session.addCallback(callback);
        }
        if (SessionState.CREATED_TOKEN_LOADED.equals(session.getState())) {
            session.openForRead(null);
        }
    }

    // add the broadcast receiver
    IntentFilter filter = new IntentFilter();
    filter.addAction(Session.ACTION_ACTIVE_SESSION_SET);
    filter.addAction(Session.ACTION_ACTIVE_SESSION_UNSET);

    // Add a broadcast receiver to listen to when the active Session
    // is set or unset, and add/remove our callback as appropriate
    broadcastManager.registerReceiver(receiver, filter);
}
 
Example 6
Source Project: custom-tabs-client   Source File: CustomTabsHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Used to check whether there is a specialized handler for a given intent.
 * @param intent The intent to check with.
 * @return Whether there is a specialized handler for the given intent.
 */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
Example 7
Source Project: android-browser-helper   Source File: CustomTabsHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Used to check whether there is a specialized handler for a given intent.
 * @param intent The intent to check with.
 * @return Whether there is a specialized handler for the given intent.
 */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
Example 8
@Override
protected void onResume() {
    super.onResume();

    // register GCM registration complete receiver.
    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(REGISTRATION_COMPLETE));

    // register new push message receiver.
    // by doing this, the activity will be notified each time a new message arrives
    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(PUSH_NOTIFICATION));

    // clear the notification area when the app is opened.
    NotificationUtils.clearNotifications(getApplicationContext());
}
 
Example 9
@Override
    public void onResume() {
        super.onResume();
        setListViewPositionFromPositionsCache();
        LocalBroadcastManager.getInstance(getActivity()).registerReceiver(newBroadcastReceiver,
                new IntentFilter(AppEventAction.NEW_MSG_BROADCAST));
        // setActionBarTabCount(newMsgTipBar.getValues().size());
        getNewMsgTipBar().setOnChangeListener(new TopTipsView.OnChangeListener() {
            @Override
            public void onChange(int count) {
//                ((MainTimeLineActivity) getActivity()).setMentionsCommentCount(count);
                // setActionBarTabCount(count);
            }
        });
        checkUnreadInfo();
    }
 
Example 10
Source Project: AppTroy   Source File: ActivityHook.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
    Log.d("cc", "before, register receiver");
    if (NEED_DEBUG) {
        Activity activity = (Activity) param.thisObject;
        Log.d(LOG_TAG, activity.toString());
    }
    if (!ModuleContext.HAS_REGISTER_LISENER) {
        Activity app = (Activity) param.thisObject;
        IntentFilter filter = new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION);
        app.registerReceiver(new CommandBroadcastReceiver(), filter);
        ModuleContext.HAS_REGISTER_LISENER = true;
        ModuleContext.getInstance().setFirstApplication(app.getApplication());
        Log.d("cc", "register over");
    }
}
 
Example 11
Source Project: Trigger   Source File: TriggerLoop.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    jobSet = new ConcurrentHashMap<>();
    receivers = new ConcurrentHashMap<>();
    jobHappens = new ConcurrentHashMap<>();
    binder = new TriggerBinder();
    executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE, new TriggerWorkerFactory());
    mainHandler = new Handler(Looper.getMainLooper());
    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    shortDeadlineHandler = new Handler();
    deadlineCheck = new DeadlineCheck();
    sDeviceStatus = DeviceStatus.get(this);
    registerReceiver(deadlineCheck, new IntentFilter(DEADLINE_BROADCAST));
    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    int granted = checkCallingOrSelfPermission("android.permission.WAKE_LOCK");
    if (granted == PackageManager.PERMISSION_GRANTED) {
        wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    } else {
        wakeLock = null;
    }
    handlerThread = new HandlerThread("Trigger-HandlerThread");
    handlerThread.start();
    checker = new CheckHandler(handlerThread.getLooper());
    mayRecoverJobsFromFile();
}
 
Example 12
Source Project: TwistyTimer   Source File: TTIntent.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Registers a broadcast receiver. The receiver will only be notified of intents that require
 * the category given and only for the actions that are supported for that category. If the
 * receiver is used by a fragment, create an instance of {@link TTFragmentBroadcastReceiver}
 * and register it with the {@link #registerReceiver(TTFragmentBroadcastReceiver)} method
 * instead, as it will be easier to maintain.
 *
 * @param receiver
 *     The broadcast receiver to be registered.
 * @param category
 *     The category for the actions to be received. Must not be {@code null} and must be a
 *     supported category.
 *
 * @throws IllegalArgumentException
 *     If the category is {@code null}, or is not one of the supported categories.
 */
public static void registerReceiver(BroadcastReceiver receiver, String category) {
    final String[] actions = ACTIONS_SUPPORTED_BY_CATEGORY.get(category);

    if (category == null || actions.length == 0) {
        throw new IllegalArgumentException("Category is not supported: " + category);
    }

    final IntentFilter filter = new IntentFilter();

    filter.addCategory(category);

    for (String action : actions) {
        // IntentFilter will only match Intents with one of these actions.
        filter.addAction(action);
    }

    LocalBroadcastManager.getInstance(TwistyTimer.getAppContext())
            .registerReceiver(receiver, filter);
}
 
Example 13
public ServerConnection(Context context) {
    mCertListener = () -> {
        Log.d(TAG, "cert added, reconnecting to server...");

        if (mSseConnection.getStatus() == SseConnection.Status.CERTIFICATE_ERROR) {
            mSseConnection.connect();
        }
    };

    mSseConnection.addListener(new SseConnectionListener());
    mSseConnection.addItemValueListener(new SseStateUpdateListener());

    CertificateManager.getInstance().addCertListener(mCertListener);
    CredentialManager.getInstance().addCredentialsListener(mSseConnection);

    IntentFilter f = new IntentFilter();
    f.addAction(Constants.INTENT_ACTION_SET_WITH_TIMEOUT);

    LocalBroadcastManager.getInstance(context).registerReceiver(mReceiver, f);
}
 
Example 14
Source Project: container   Source File: IntentResolver.java    License: GNU General Public License v3.0 6 votes vote down vote up
private ArrayList<F> collectFilters(F[] array, IntentFilter matching) {
	ArrayList<F> res = null;
	if (array != null) {
		for (int i = 0; i < array.length; i++) {
			F cur = array[i];
			if (cur == null) {
				break;
			}
			if (filterEquals(cur, matching)) {
				if (res == null) {
					res = new ArrayList<>();
				}
				res.add(cur);
			}
		}
	}
	return res;
}
 
Example 15
Source Project: slide-android   Source File: SystemSettings.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean isUsbConnected(final Activity a)
{
    final Intent intent = a.registerReceiver(
        null, new IntentFilter(
            "android.hardware.usb.action.USB_STATE")
    );
    return intent != null && intent.getExtras().getBoolean("connected");
}
 
Example 16
Source Project: oversec   Source File: App.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {

    int pid = Process.myPid();
    ActivityManager manager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    String currentProcName = null;
    for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {
        if (processInfo.pid == pid) {
            currentProcName = processInfo.processName;
            break;
        }
    }

    if (currentProcName.endsWith("zxcvbn")) {
        super.onCreate();
        return;
    }

    CrashHandler.init(this);

    LoggingConfig.INSTANCE.init(BuildConfig.DEBUG);

    super.onCreate();

    if (IabUtil.isGooglePlayInstalled(this)) {
        RateThisApp.Config config = new RateThisApp.Config(7, 30);
        RateThisApp.init(config);
    }

    //need to register from code, registering from manifest is ignored
    IntentFilter packageChangeFilter = new IntentFilter();
    packageChangeFilter.addAction("android.intent.action.PACKAGE_ADDED");
    packageChangeFilter.addAction("android.intent.action.PACKAGE_REMOVED");
    packageChangeFilter.addAction("android.intent.action.PACKAGE_CHANGED");
    packageChangeFilter.addDataScheme("package");
    registerReceiver(new AppsReceiver(), packageChangeFilter);

    IabUtil.getInstance(this);
    Core.getInstance(this);
}
 
Example 17
Source Project: a   Source File: ReadAloudService.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void initBroadcastReceiver() {
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(action)) {
                pauseReadAloud(true);
            }
        }
    };
    IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    registerReceiver(broadcastReceiver, intentFilter);
}
 
Example 18
Source Project: Bolts-Android   Source File: AppLinkTest.java    License: MIT License 5 votes vote down vote up
public void testGeneralMeasurementEventsBroadcast() throws Exception {
  Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
  i.putExtra("foo", "bar");
  ArrayList<String> arr = new ArrayList<>();
  arr.add("foo2");
  arr.add("bar2");
  i.putExtra("foobar", arr);
  Map<String, String> other = new HashMap<>();
  other.put("yetAnotherFoo", "yetAnotherBar");

  final CountDownLatch lock = new CountDownLatch(1);
  final String[] receivedStrings = new String[5];
  LocalBroadcastManager manager = LocalBroadcastManager.getInstance(instrumentation.getTargetContext());
  manager.registerReceiver(
      new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
          String eventName = intent.getStringExtra("event_name");
          Bundle eventArgs = intent.getBundleExtra("event_args");
          receivedStrings[0] = eventName;
          receivedStrings[1] = eventArgs.getString("foo");
          receivedStrings[2] = eventArgs.getString("foobar");
          receivedStrings[3] = eventArgs.getString("yetAnotherFoo");
          receivedStrings[4] = eventArgs.getString("intentData");
          lock.countDown();
        }
      },
      new IntentFilter("com.parse.bolts.measurement_event")
  );

  MeasurementEvent.sendBroadcastEvent(instrumentation.getTargetContext(), "myEventName", i, other);
  lock.await(20000, TimeUnit.MILLISECONDS);

  assertEquals("myEventName", receivedStrings[0]);
  assertEquals("bar", receivedStrings[1]);
  assertEquals((new JSONArray(arr)).toString(), receivedStrings[2]);
  assertEquals("yetAnotherBar", receivedStrings[3]);
  assertEquals("http://www.example.com", receivedStrings[4]);
}
 
Example 19
Source Project: Gizwits-SmartBuld_Android   Source File: InactivityTimer.java    License: MIT License 5 votes vote down vote up
public synchronized void onResume() {
	if (registered) {
		Log.w(TAG, "PowerStatusReceiver was already registered?");
	} else {
		activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
		registered = true;
	}
	onActivity();
}
 
Example 20
Source Project: wearable   Source File: BatmanWatchFaceService.java    License: Apache License 2.0 5 votes vote down vote up
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    BatmanWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
Example 21
Source Project: Camera-Roll-Android-App   Source File: AlbumActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public IntentFilter getBroadcastIntentFilter() {
    IntentFilter filter = FileOperation.Util.getIntentFilter(super.getBroadcastIntentFilter());
    filter.addAction(ALBUM_ITEM_REMOVED);
    filter.addAction(ALBUM_ITEM_RENAMED);
    filter.addAction(DATA_CHANGED);
    return filter;
}
 
Example 22
Source Project: bither-android   Source File: BlockchainService.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized void startPeer() {
    try {
        if (peerCanNotRun) {
            return;
        }
        if (UpgradeUtil.needUpgrade()) {
            return;
        }
        if (!AppSharedPreference.getInstance().getDownloadSpvFinish()) {
            Block block = BlockUtil.dowloadSpvBlock();
            if (block == null) {
                return;
            }
        }
        if (AppSharedPreference.getInstance().getAppMode() != BitherjSettings.AppMode.COLD) {
            if (!AppSharedPreference.getInstance().getBitherjDoneSyncFromSpv()) {
                if (!PeerManager.instance().isConnected()) {
                    PeerManager.instance().start();
                    if (!spvFinishedReceivered) {
                        final IntentFilter intentFilter = new IntentFilter();
                        intentFilter.addAction(NotificationAndroidImpl.ACTION_SYNC_FROM_SPV_FINISHED);
                        spvFinishedReceiver = new SPVFinishedReceiver();
                        registerReceiver(spvFinishedReceiver, intentFilter);
                        spvFinishedReceivered = true;
                    }
                }
            } else {
                if (!AddressManager.getInstance().addressIsSyncComplete()) {
                    TransactionsUtil.getMyTxFromBither();
                }
                startPeerManager();

            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example 23
Source Project: NightWatch   Source File: ShareGlucose.java    License: GNU General Public License v3.0 5 votes vote down vote up
public int getBatteryLevel() {
    Intent batteryIntent = mContext.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
    if(level == -1 || scale == -1) {
        return 50;
    }
    return (int)(((float)level / (float)scale) * 100.0f);
}
 
Example 24
Source Project: xDrip   Source File: PowerStateReceiver.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
public static int getBatteryLevel(Context context) {
    final Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    try {
        int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
        if (level == -1 || scale == -1) {
            return 50;
        }
        return (int) (((float) level / (float) scale) * 100.0f);
    } catch (NullPointerException e) {
        return 50;
    }
}
 
Example 25
Source Project: YCVideoPlayer   Source File: FloatLifecycle.java    License: Apache License 2.0 5 votes vote down vote up
FloatLifecycle(Context applicationContext, boolean showFlag, Class[] activities, LifecycleListener lifecycleListener) {
    this.showFlag = showFlag;
    this.activities = activities;
    mLifecycleListener = lifecycleListener;
    mHandler = new Handler();
    ((Application) applicationContext).registerActivityLifecycleCallbacks(this);
    applicationContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
 
Example 26
Source Project: android-openslmediaplayer   Source File: AppEventBus.java    License: Apache License 2.0 5 votes vote down vote up
private static IntentFilter createIntentFilter(Receiver<?> receiver) {
    int[] categories = receiver.getCategoryFilter();
    IntentFilter filter = new IntentFilter();

    if (categories != null) {
        for (int category : categories) {
            filter.addAction(categoryToActionName(category));
        }
    }

    return filter;
}
 
Example 27
@Override
protected void provide() {
    BluetoothAdapter BTAdapter = BluetoothAdapter.getDefaultAdapter();               // Set up the adaptor
    if (BTAdapter == null || !BTAdapter.isEnabled()) {
        this.finish();
        return;
    }
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(android.bluetooth.BluetoothDevice.ACTION_FOUND);
    intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
    intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    getContext().registerReceiver(mReceiver, intentFilter);
    BTAdapter.startDiscovery();
}
 
Example 28
Source Project: Taskbar   Source File: StartMenuLayoutTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDispatchKeyEvent() {
    IntentFilter filter = new IntentFilter(ACTION_HIDE_START_MENU);
    TestBroadcastReceiver receiver = new TestBroadcastReceiver();
    LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter);
    KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
    layout.dispatchKeyEvent(keyEvent);
    assertFalse(receiver.onReceived);
    layout.viewHandlesBackButton();
    layout.dispatchKeyEvent(keyEvent);
    assertTrue(receiver.onReceived);
}
 
Example 29
@Override
protected void onResume() {
    super.onResume();

    LocalBroadcastManager.getInstance(this).registerReceiver(refreshReceiver, new IntentFilter("contact_refresh"));

    bindService(new Intent(this, MainService.class), this, Service.BIND_AUTO_CREATE);
}
 
Example 30
Source Project: android_9.0.0_r45   Source File: Watchdog.java    License: Apache License 2.0 5 votes vote down vote up
public void init(Context context, ActivityManagerService activity) {
    mResolver = context.getContentResolver();
    mActivity = activity;

    context.registerReceiver(new RebootRequestReceiver(),
            new IntentFilter(Intent.ACTION_REBOOT),
            android.Manifest.permission.REBOOT, null);
}