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.react.modules.netinfo.NetInfoModule.java

private void registerReceiver() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    getReactApplicationContext().registerReceiver(mConnectivityBroadcastReceiver, filter);
    mConnectivityBroadcastReceiver.setRegistered(true);
}

From source file:com.android.incallui.CircularRevealActivity.java

@Override
protected void onStart() {
    super.onStart();
    if (!InCallPresenter.getInstance().isServiceBound()) {
        clearDisplay();/*from   w  w w  .ja v a2  s .c  o  m*/
    }
    final IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_CLEAR_DISPLAY);
    LocalBroadcastManager.getInstance(this).registerReceiver(mClearDisplayReceiver, filter);
}

From source file:com.example.jinux.mydemo.s3.UploadService.java

@Override
public void onCreate() {
    super.onCreate();
    s3Client = new AmazonS3Client(new CognitoCachingCredentialsProvider(getApplicationContext(),
            "us-east-1:c0202ae8-4b11-407e-bb84-a3d66cee370e", Regions.US_EAST_1));
    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    IntentFilter f = new IntentFilter();
    f.addAction(UPLOAD_CANCELLED_ACTION);
    registerReceiver(uploadCancelReceiver, f);
}

From source file:com.adam.aslfms.UserCredActivity.java

@Override
protected void onResume() {
    super.onResume();

    IntentFilter ifs = new IntentFilter();
    ifs.addAction(ScrobblingService.BROADCAST_ONAUTHCHANGED);
    registerReceiver(onAuthChange, ifs);

    update();//from   w  w w  .  j  a  v  a 2  s.  c o m
}

From source file:com.polyvi.xface.extension.XBatteryExt.java

@Override
public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException {
    XExtensionResult.Status status = XExtensionResult.Status.INVALID_ACTION;
    String result = "Unsupported Operation: " + action;
    if (COMMAND_START.equals(action)) {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
        final XCallbackContext cbCtx = callbackCtx;
        if (null == mBroadcastReceiver) {
            mBroadcastReceiver = new BroadcastReceiver() {
                @Override/* w  w  w .j  av  a2 s.com*/
                public void onReceive(Context context, Intent intent) {
                    XLog.d(CLASS_NAME, "received broadcast of battery changing");
                    updateBatteryInfo(intent, cbCtx);
                }
            };
            getContext().registerReceiver(mBroadcastReceiver, intentFilter);
        }
        XExtensionResult extensionResult = new XExtensionResult(XExtensionResult.Status.NO_RESULT);
        extensionResult.setKeepCallback(true);
        return extensionResult;
    } else if (COMMAND_STOP.equals(action)) {
        removeBatteryListener();
        sendUpdate(new JSONObject(), callbackCtx, false);
        return new XExtensionResult(XExtensionResult.Status.OK);
    }
    return new XExtensionResult(status, result);
}

From source file:com.coinblesk.client.wallet.Outputs.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    Intent walletServiceIntent = new Intent(getActivity(), WalletService.class);
    getActivity().bindService(walletServiceIntent, serviceConnection, Context.BIND_AUTO_CREATE);

    adapter = new OutputsAdapter(null, this);

    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
    IntentFilter coinsSentOrReceivedFilter = new IntentFilter();
    coinsSentOrReceivedFilter.addAction(Constants.WALLET_COINS_SENT_ACTION);
    coinsSentOrReceivedFilter.addAction(Constants.WALLET_COINS_RECEIVED_ACTION);
    broadcastManager.registerReceiver(onCoinsSentOrReceived, coinsSentOrReceivedFilter);
}

From source file:com.linkedin.android.shaky.FeedbackActivity.java

@Override
protected void onResumeFragments() {
    super.onResumeFragments();

    IntentFilter filter = new IntentFilter();
    filter.addAction(FeedbackTypeAdapter.ACTION_FEEDBACK_TYPE_SELECTED);
    filter.addAction(FormFragment.ACTION_SUBMIT_FEEDBACK);
    filter.addAction(FormFragment.ACTION_EDIT_IMAGE);
    filter.addAction(DrawFragment.ACTION_DRAWING_COMPLETE);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter);
}

From source file:com.remobile.batteryStatus.BatteryListener.java

/**
 * Executes the request.//w ww .  ja  v  a  2  s .c  o m
 *
 * @param action           The action to execute.
 * @param args             JSONArry of arguments for the plugin.
 * @param callbackContext    The callback context used when calling back into JavaScript.
 * @return                 True if the action was valid, false if not.
 */
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
    if (action.equals("start")) {
        // We need to listen to power events to update battery status
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
        if (this.receiver == null) {
            this.receiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    updateBatteryInfo(intent);
                }
            };
            getReactApplicationContext().registerReceiver(this.receiver, intentFilter);
        }

        // Don't return any result now, since status results will be sent when events come in from broadcast receiver
        callbackContext.success();
        return true;
    }

    else if (action.equals("stop")) {
        removeBatteryListener();
        callbackContext.success();
        return true;
    }

    return false;
}

From source file:com.adam.aslfms.UserCredsListActivity.java

@Override
protected void onResume() {
    super.onResume();

    IntentFilter ifs = new IntentFilter();
    ifs.addAction(ScrobblingService.BROADCAST_ONAUTHCHANGED);

    registerReceiver(onStatusChange, ifs);
    update();//  w w w .j  ava 2 s  . c o  m
}

From source file:com.google.android.apps.forscience.whistlepunk.devicemanager.ManageDevicesActivity.java

private void registerBtReceiverIfNecessary() {
    if (mBtReceiver == null) {
        mBtReceiver = new BroadcastReceiver() {
            @Override/*from ww w  .j av  a 2 s  .  c  o  m*/
            public void onReceive(Context context, Intent intent) {
                setFragment();
            }
        };
        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        registerReceiver(mBtReceiver, filter);
    }
}