Java Code Examples for android.app.Activity#unregisterReceiver()

The following examples show how to use android.app.Activity#unregisterReceiver() . 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
Source File: RNCAppearanceModule.java    From react-native-appearance with MIT License 5 votes vote down vote up
@Override
public void onHostPause() {
    final Activity activity = getCurrentActivity();
    if (activity == null) return;
    try  {
        activity.unregisterReceiver(mBroadcastReceiver);
    } catch (java.lang.IllegalArgumentException e) {
        FLog.e(ReactConstants.TAG, "mBroadcastReceiver already unregistered", e);
    }
}
 
Example 2
Source File: DictionarySettingsFragment.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();
    final Activity activity = getActivity();
    UpdateHandler.unregisterUpdateEventListener(this);
    activity.unregisterReceiver(mConnectivityChangedReceiver);
    if (mChangedSettings) {
        final Intent newDictBroadcast =
                new Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
        activity.sendBroadcast(newDictBroadcast);
        mChangedSettings = false;
    }
}
 
Example 3
Source File: OrientationModule.java    From react-native-orientation-locker with MIT License 5 votes vote down vote up
@Override
public void onHostPause() {
    FLog.d(ReactConstants.TAG, "orientation detect disabled.");
    mOrientationListener.disable();

    final Activity activity = getCurrentActivity();
    if (activity == null) return;
    try
    {
        activity.unregisterReceiver(mReceiver);
    }
    catch (java.lang.IllegalArgumentException e) {
        FLog.w(ReactConstants.TAG, "Receiver already unregistered", e);
    }
}
 
Example 4
Source File: OrientationModule.java    From react-native-orientation-locker with MIT License 5 votes vote down vote up
@Override
public void onHostDestroy() {
    FLog.d(ReactConstants.TAG, "orientation detect disabled.");
    mOrientationListener.disable();

    final Activity activity = getCurrentActivity();
    if (activity == null) return;
    try
    {
        activity.unregisterReceiver(mReceiver);
    }
    catch (java.lang.IllegalArgumentException e) {
        FLog.w(ReactConstants.TAG, "Receiver already unregistered", e);
    }
}
 
Example 5
Source File: DictionarySettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();
    final Activity activity = getActivity();
    UpdateHandler.unregisterUpdateEventListener(this);
    activity.unregisterReceiver(mConnectivityChangedReceiver);
    if (mChangedSettings) {
        Context context = activity.getApplicationContext();
        final Intent newDictBroadcast =
                new Intent(new DictionaryPackConstants(context).NEW_DICTIONARY_INTENT_ACTION);
        activity.sendBroadcast(newDictBroadcast);
        mChangedSettings = false;
    }
}
 
Example 6
Source File: USB.java    From OkUSB with Apache License 2.0 5 votes vote down vote up
/**
 * 取消注册
 */
public void destroy() {
    Activity activity = ctx.get();
    if (activity != null) {
        activity.unregisterReceiver(mUsbPermissionActionReceiver);
    }
    disConnectDevice();
    onUsbChangeListener = null;
}
 
Example 7
Source File: ConfirmationFragment.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();
    Activity activity = getActivity();
    if (activity != null) {
        activity.unregisterReceiver(mReceiver);
    }
}
 
Example 8
Source File: PluginActivityMonitor.java    From Android-Plugin-Framework with MIT License 5 votes vote down vote up
public void onActivityDestory(Activity activity) {
	if (!activity.isChild()) {
		if (activity.getClass().getClassLoader() instanceof RealPluginClassLoader) {
			BroadcastReceiver br = receivers.remove(activity);
			LogUtil.v("unregisterReceiver", br.getClass().getName());
			activity.unregisterReceiver(br);
		}
	}
}
 
Example 9
Source File: SessionActivityRegistration.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
/**
 * Stop activity from listening for session expiration broadcasts.  Call
 * this method in onPause methods of activities that are session sensitive.
 */
public static void unregisterSessionExpirationReceiver(Activity activity) {
    try {
        activity.unregisterReceiver(userSessionExpiredReceiver);
    } catch (IllegalArgumentException e) {
        Log.w(TAG, "Trying to unregister the session expiration receiver " +
                "that wasn't previously registerd.");
    }
}
 
Example 10
Source File: DictionarySettingsFragment.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();
    final Activity activity = getActivity();
    UpdateHandler.unregisterUpdateEventListener(this);
    activity.unregisterReceiver(mConnectivityChangedReceiver);
    if (mChangedSettings) {
        final Intent newDictBroadcast =
                new Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
        activity.sendBroadcast(newDictBroadcast);
        mChangedSettings = false;
    }
}
 
Example 11
Source File: SamsungBleStack.java    From awesomesauce-rfduino with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** Stop looking for Bluetooth Low Energy devices. **/
public static void stopLeScan(Activity hostActivity) {
	if (scanning){
	//Stop responding to found items:
	hostActivity.unregisterReceiver(onBluetoothFoundReceiver);
	if (BluetoothAdapter.getDefaultAdapter().isDiscovering()){
		BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
	}
	scanning = false;
	}
}
 
Example 12
Source File: ConnectivityReceiver.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
public void unregister(Activity aActivity) {
    aActivity.unregisterReceiver(this);
    mDelegate = null;
}
 
Example 13
Source File: JsDevReloadHandler.java    From react-native-navigation with MIT License 4 votes vote down vote up
public void onActivityPaused(Activity activity) {
	activity.unregisterReceiver(reloadReceiver);
}
 
Example 14
Source File: HeadSetReceiver.java    From FamilyChat with Apache License 2.0 4 votes vote down vote up
/**
 * 解绑广播的公共方法
 */
public static void unregistFromActivity(Activity activity, HeadSetReceiver receiver)
{
    activity.unregisterReceiver(receiver);
}
 
Example 15
Source File: GpsServiceUtilities.java    From geopaparazzi with GNU General Public License v3.0 2 votes vote down vote up
/**
 * unregister an activity from {@link GpsService} broadcasts.
 *
 * @param activity the activity.
 * @param receiver the receiver.
 */
public static void unregisterFromBroadcasts(Activity activity, BroadcastReceiver receiver) {
    if (receiver != null)
        activity.unregisterReceiver(receiver);
}