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

The following examples show how to use android.app.Activity#unregisterReceiver() . 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 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
@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
@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
@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
@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 Project: OkUSB   File: USB.java    License: 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
@Override
public void onPause() {
    super.onPause();
    Activity activity = getActivity();
    if (activity != null) {
        activity.unregisterReceiver(mReceiver);
    }
}
 
Example 8
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
/**
 * 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
@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
/** 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
public void unregister(Activity aActivity) {
    aActivity.unregisterReceiver(this);
    mDelegate = null;
}
 
Example 13
public void onActivityPaused(Activity activity) {
	activity.unregisterReceiver(reloadReceiver);
}
 
Example 14
Source Project: FamilyChat   File: HeadSetReceiver.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 解绑广播的公共方法
 */
public static void unregistFromActivity(Activity activity, HeadSetReceiver receiver)
{
    activity.unregisterReceiver(receiver);
}
 
Example 15
/**
 * 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);
}