Example usage for android.content IntentFilter addAction

List of usage examples for android.content IntentFilter addAction

Introduction

In this page you can find the example usage for android.content IntentFilter addAction.

Prototype

public final void addAction(String action) 

Source Link

Document

Add a new Intent action to match against.

Usage

From source file:com.facebook.SessionTests.java

static IntentFilter getActiveSessionFilter(String... actions) {
    IntentFilter filter = new IntentFilter();

    for (String action : actions) {
        filter.addAction(action);
    }//from   w  w w . ja v  a 2  s  .  c  om

    return filter;
}

From source file:com.buddi.client.dfu.DfuActivity.java

private static IntentFilter makeDfuUpdateIntentFilter() {
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(DfuService.BROADCAST_PROGRESS);
    intentFilter.addAction(DfuService.BROADCAST_ERROR);
    intentFilter.addAction(DfuService.BROADCAST_LOG);
    return intentFilter;
}

From source file:org.metawatch.manager.Monitors.java

private static void createWifiReceiver(final Context context) {
    if (wifiReceiver != null)
        return;//from  www .ja  v  a  2  s .c  o  m
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wm.getConnectionInfo();
    if (info != null)
        SignalData.wifiBars = 1 + WifiManager.calculateSignalLevel(info.getRssi(), 4);
    wifiReceiver = new BroadcastReceiver() {
        int wifiBars = 0;

        @Override
        public void onReceive(Context c, Intent intent) {
            String action = intent.getAction();
            if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
                if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
                        WifiManager.WIFI_STATE_UNKNOWN) != WifiManager.WIFI_STATE_ENABLED) {
                    wifiBars = 0;
                }
            } else if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) {
                if (!intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)) {
                    wifiBars = 0;
                }
            } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
                NetworkInfo netInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
                if (netInfo.getState() != NetworkInfo.State.CONNECTED) {
                    wifiBars = 0;
                } else {
                    WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO);
                    if (wifiInfo == null) {
                        wifiBars = 0;
                    } else {
                        wifiBars = 1 + WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 4);
                    }
                }
            } else if (action.equals(WifiManager.RSSI_CHANGED_ACTION)) {
                final int newRssi = intent.getIntExtra(WifiManager.EXTRA_NEW_RSSI, -200);
                wifiBars = 1 + WifiManager.calculateSignalLevel(newRssi, 4);
            }
            if (wifiBars != SignalData.wifiBars) {
                SignalData.wifiBars = wifiBars;
                Idle.updateIdle(context, true);
            }
        }
    };
    IntentFilter f = new IntentFilter();
    f.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    f.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
    f.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    f.addAction(WifiManager.RSSI_CHANGED_ACTION);
    context.registerReceiver(wifiReceiver, f);
}

From source file:com.auth0.lock.core.AuthenticationReceiver.java

public AuthenticationReceiver(LocalBroadcastManager broadcastManager, LockBase.LockCallback callback) {
    this.callback = callback;

    this.broadcastManager = broadcastManager;
    IntentFilter filter = new IntentFilter();
    filter.addAction(LockBaseActivity.AUTHENTICATION_ACTION);
    filter.addAction(LockBaseActivity.CANCEL_ACTION);
    filter.addAction(LockBaseActivity.CHANGE_PASSWORD_ACTION);
    this.broadcastManager.registerReceiver(this, filter);
}

From source file:com.googlecode.eyesfree.brailleback.FocusTracker.java

public void register() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    mAccessibilityService.registerReceiver(this, filter);
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.presence.MusicPresence.java

@Override
public void onPresenceUpdated(final Context context, final Uri feedUri, boolean present) {
    if (mShareMusic) {
        if (getFeedsWithPresence().size() == 0) {
            context.getApplicationContext().unregisterReceiver(mReceiver);
            Toast.makeText(context, "No longer sharing music", Toast.LENGTH_SHORT).show();
            mShareMusic = false;/*from w  w  w  . ja  v  a  2  s. c o  m*/
        }
    } else {
        if (getFeedsWithPresence().size() > 0) {
            IntentFilter iF = new IntentFilter();
            iF.addAction("com.android.music.metachanged");
            context.getApplicationContext().registerReceiver(mReceiver, iF);
            Toast.makeText(context, "Now sharing music", Toast.LENGTH_SHORT).show();
            mShareMusic = true;
        }
    }
}

From source file:com.auth0.lock.receiver.AuthenticationReceiver.java

/**
 * Registers in the supplied LocalBroadcastManager
 * @param broadcastManager in which the receiver is registered
 *///from   www.  jav a 2s .co  m
public void registerIn(LocalBroadcastManager broadcastManager) {
    IntentFilter filter = new IntentFilter();
    filter.addAction(Lock.AUTHENTICATION_ACTION);
    filter.addAction(Lock.CANCEL_ACTION);
    filter.addAction(Lock.CHANGE_PASSWORD_ACTION);
    broadcastManager.registerReceiver(this, filter);
}

From source file:com.facebook.ProfileTracker.java

private void addBroadcastReceiver() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(ProfileManager.ACTION_CURRENT_PROFILE_CHANGED);

    broadcastManager.registerReceiver(receiver, filter);
}

From source file:com.facebook.AccessTokenTracker.java

private void addBroadcastReceiver() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(AccessTokenManager.ACTION_CURRENT_ACCESS_TOKEN_CHANGED);

    broadcastManager.registerReceiver(receiver, filter);
}

From source file:ac.robinson.bettertogether.api.messaging.PluginConnectionDelegate.java

public void onCreate(@SuppressWarnings("UnusedParameters") @Nullable Bundle savedInstanceState) {
    // note: savedInstanceState is passed for potential future usage; unused for now
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(PluginIntent.ACTION_STOP_PLUGIN);
    intentFilter.addAction(PluginIntent.ACTION_MESSAGE_RECEIVED);
    LocalBroadcastManager.getInstance(mContext).registerReceiver(mLocalBroadcastReceiver, intentFilter);
}