Example usage for android.support.v4.content LocalBroadcastManager unregisterReceiver

List of usage examples for android.support.v4.content LocalBroadcastManager unregisterReceiver

Introduction

In this page you can find the example usage for android.support.v4.content LocalBroadcastManager unregisterReceiver.

Prototype

public void unregisterReceiver(BroadcastReceiver receiver) 

Source Link

Document

Unregister a previously registered BroadcastReceiver.

Usage

From source file:com.sonymobile.dronecontrol.activity.MainActivity.java

private void unregisterReceivers() {
    LocalBroadcastManager localBroadcastMgr = LocalBroadcastManager.getInstance(getApplicationContext());
    localBroadcastMgr.unregisterReceiver(ardiscoveryServicesDevicesListUpdatedReceiver);
}

From source file:activeng.pt.activenglab.BluetoothChatService.java

/**
 * Stop all threads// ww  w. j ava  2  s.  c  o  m
 */
public synchronized void stop() {
    Log.d(TAG, "stop");

    if (mConnectThread != null) {
        mConnectThread.cancel();
        mConnectThread = null;
    }

    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    if (mSecureAcceptThread != null) {
        mSecureAcceptThread.cancel();
        mSecureAcceptThread = null;
    }

    if (mInsecureAcceptThread != null) {
        mInsecureAcceptThread.cancel();
        mInsecureAcceptThread = null;
    }

    deviceName = "";
    deviceAddress = "";
    setState(Constants.STATE_NONE);

    Log.d("ActivEng", "BluetoothChatService unregisterReceiver stop()");
    if (registered) {
        //mContext.getApplicationContext().unregisterReceiver(this.connectionUpdates);
        //LocalBroadcastManager.getInstance(mContext.getApplicationContext()).unregisterReceiver(this.connectionUpdates);
        LocalBroadcastManager manager = LocalBroadcastManager.getInstance(mContext);
        manager.unregisterReceiver(this.connectionUpdates);
        registered = false;
    }

}

From source file:cs.umass.edu.prepare.view.activities.CalendarActivity.java

@Override
protected void onStop() {
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
    try {//from w  w  w  .  j ava  2s .co  m
        broadcastManager.unregisterReceiver(receiver);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
    super.onStop();
}

From source file:com.facebook.widget.LikeView.java

private void tearDownObjectAssociations() {
    if (broadcastReceiver != null) {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getContext());
        localBroadcastManager.unregisterReceiver(broadcastReceiver);

        broadcastReceiver = null;//from w  ww . j a va2  s.co  m
    }

    // If we were already waiting on a controller to be given back, make sure we aren't waiting anymore.
    // Otherwise when that controller is given back to the callback, it will go and register a broadcast receiver
    // for it.
    if (creationCallback != null) {
        creationCallback.cancel();

        creationCallback = null;
    }

    likeActionController = null;
}

From source file:com.facebook.AppEventsLoggerTests.java

public void testSimpleCall() throws InterruptedException {
    AppEventsLogger.setFlushBehavior(AppEventsLogger.FlushBehavior.EXPLICIT_ONLY);

    TestSession session1 = TestSession.createSessionWithSharedUser(getActivity(), null);
    TestSession session2 = TestSession.createSessionWithSharedUser(getActivity(), null, SECOND_TEST_USER_TAG);

    AppEventsLogger logger1 = AppEventsLogger.newLogger(getActivity(), session1);
    AppEventsLogger logger2 = AppEventsLogger.newLogger(getActivity(), session2);

    final WaitForBroadcastReceiver waitForBroadcastReceiver = new WaitForBroadcastReceiver();
    waitForBroadcastReceiver.incrementExpectCount();

    final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());

    // Need to get notifications on another thread so we can wait for them.
    runOnBlockerThread(new Runnable() {
        @Override//from   www .  j  a v  a 2  s .  co  m
        public void run() {
            broadcastManager.registerReceiver(waitForBroadcastReceiver,
                    new IntentFilter(AppEventsLogger.ACTION_APP_EVENTS_FLUSHED));
        }
    }, true);

    logger1.logEvent("an_event");
    logger2.logEvent("another_event");

    logger1.flush();

    waitForBroadcastReceiver.waitForExpectedCalls();

    closeBlockerAndAssertSuccess();

    broadcastManager.unregisterReceiver(waitForBroadcastReceiver);
}

From source file:com.coinblesk.client.KeyboardFragment.java

@Override
public void onStop() {
    super.onStop();
    this.getActivity().unbindService(serviceConnection);
    LocalBroadcastManager broadcaster = LocalBroadcastManager.getInstance(getActivity());
    broadcaster.unregisterReceiver(exchangeRateChangeListener);
    broadcaster.unregisterReceiver(instantPaymentErrorListener);
    broadcaster.unregisterReceiver(instantPaymentSuccessListener);
    broadcaster.unregisterReceiver(insufficientFundsListener);
}

From source file:com.coinblesk.client.MainActivity.java

@Override
protected void onStop() {
    super.onStop();
    Log.d(TAG, "onStop");

    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
    broadcastManager.unregisterReceiver(startClientsBroadcastReceiver);
    broadcastManager.unregisterReceiver(stopClientsBroadcastReceiver);
    broadcastManager.unregisterReceiver(startServersBroadcastReceiver);

    broadcastManager.unregisterReceiver(instantPaymentSuccessListener);

    this.stopServers();

    unbindService(serviceConnection);//from ww  w.j av  a2 s  .  c  o  m
}

From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.hplus.HPlusSupport.java

@Override
public void dispose() {
    LOG.debug("Dispose");
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
    broadcastManager.unregisterReceiver(mReceiver);

    close();/* ww w. j a va 2s. co  m*/

    super.dispose();
}

From source file:com.facebook.LikeView.java

private void tearDownObjectAssociations() {
    if (broadcastReceiver != null) {
        LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getContext());
        localBroadcastManager.unregisterReceiver(broadcastReceiver);

        broadcastReceiver = null;/*from   w  ww .j av  a  2s  . com*/
    }

    // If we were already waiting on a controller to be given back, make sure we aren't waiting
    // anymore. Otherwise when that controller is given back to the callback, it will go and
    // register a broadcast receiver for it.
    if (creationCallback != null) {
        creationCallback.cancel();

        creationCallback = null;
    }

    likeActionController = null;
}

From source file:com.facebook.AppEventsLoggerTests.java

@SuppressWarnings("deprecation")
public void testInsightsLoggerCompatibility() throws InterruptedException {
    AppEventsLogger.setFlushBehavior(AppEventsLogger.FlushBehavior.AUTO);

    TestSession session1 = TestSession.createSessionWithSharedUser(getActivity(), null);

    InsightsLogger logger1 = InsightsLogger.newLogger(getActivity(), null, null, session1);

    final WaitForBroadcastReceiver waitForBroadcastReceiver = new WaitForBroadcastReceiver();
    waitForBroadcastReceiver.incrementExpectCount();

    final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());

    // Need to get notifications on another thread so we can wait for them.
    runOnBlockerThread(new Runnable() {
        @Override/*w w w  . j  a v  a  2 s. co m*/
        public void run() {
            broadcastManager.registerReceiver(waitForBroadcastReceiver,
                    new IntentFilter(AppEventsLogger.ACTION_APP_EVENTS_FLUSHED));
        }
    }, true);

    logger1.logConversionPixel("foo", 1.0);

    // For some reason the flush can take an extraordinary amount of time, so increasing
    // the timeout here to prevent failures.
    waitForBroadcastReceiver.waitForExpectedCalls(600 * 1000);

    closeBlockerAndAssertSuccess();

    broadcastManager.unregisterReceiver(waitForBroadcastReceiver);
}