Handles send intents from multitude of Android applications
483721
private void encodeContentsFromShareIntent(Intent intent) throws WriterException {
    // Check if this is a plain text encoding, or contact
    if (intent.hasExtra(Intent.EXTRA_STREAM)) {
      encodeFromStreamExtra(intent);
    } else {
      encodeFromTextExtras(intent);
    }
  }
976847
private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {

    if (barcode != null) {
      viewfinderView.drawResultBitmap(barcode);
    }

    long resultDurationMS;
    if (getIntent() == null) {
      resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS;
    } else {
      resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS,
                                                  DEFAULT_INTENT_RESULT_DURATION_MS);
    }

    if (resultDurationMS > 0) {
      String rawResultString = String.valueOf(rawResult);
      if (rawResultString.length() > 32) {
        rawResultString = rawResultString.substring(0, 32) + " ...";
      }
      statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
    }

    maybeSetClipboard(resultHandler);

    switch (source) {
      case NATIVE_APP_INTENT:
        // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
        // the deprecated intent is retired.
        Intent intent = new Intent(getIntent().getAction());
        intent.addFlags(Intents.FLAG_NEW_DOC);
        intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
        intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
        byte[] rawBytes = rawResult.getRawBytes();
        if (rawBytes != null && rawBytes.length > 0) {
          intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
        }
        Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata();
        if (metadata != null) {
          if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
            intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
                metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
          }
          Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
          if (orientation != null) {
            intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
          }
          String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
          if (ecLevel != null) {
            intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
          }
          @SuppressWarnings("unchecked")
          Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
          if (byteSegments != null) {
            int i = 0;
            for (byte[] byteSegment : byteSegments) {
              intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
              i++;
            }
          }
        }
        sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS);
        break;

      case PRODUCT_SEARCH_LINK:
        // Reformulate the URL which triggered us into a query, so that the request goes to the same
        // TLD as the scan URL.
        int end = sourceUrl.lastIndexOf("/scan");
        String productReplyURL = sourceUrl.substring(0, end) + "?q=" + 
            resultHandler.getDisplayContents() + "&source=zxing";
        sendReplyMessage(R.id.launch_product_query, productReplyURL, resultDurationMS);
        break;
        
      case ZXING_LINK:
        if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) {
          String linkReplyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler);
          scanFromWebPageManager = null;
          sendReplyMessage(R.id.launch_product_query, linkReplyURL, resultDurationMS);
        }
        break;
    }
  }
1160571
@Override
    public void onReceive(Context context, Intent intent) {
        // display errors to the user
        Bundle bundle = intent.getExtras();
        if (intent.getAction().equals(DDPStateSingleton.MESSAGE_ERROR)) {
            String message = bundle
                    .getString(DDPStateSingleton.MESSAGE_EXTRA_MSG);
            onError("Login Error", message);
        } else if (intent.getAction().equals(
                DDPStateSingleton.MESSAGE_CONNECTION)) {
            int state = bundle.getInt(DDPStateSingleton.MESSAGE_EXTRA_STATE);
            if (state == DDPStateSingleton.DDPSTATE.Closed.ordinal()) {
                // connection was closed, show error message
                onError("Disconnected",
                        "Websocket to server was closed");
            } else if (state == DDPStateSingleton.DDPSTATE.Connected.ordinal()) {
                onDDPConnect(mDDP);
            } else if (state == DDPStateSingleton.DDPSTATE.LoggedIn.ordinal()) {
                onLogin();
            } else if (state == DDPStateSingleton.DDPSTATE.NotLoggedIn.ordinal()) {
                onLogout();
            }
        } else if (intent.getAction().equals(
                DDPStateSingleton.MESSAGE_SUBUPDATED)) {
            String subscriptionName = bundle
                    .getString(DDPStateSingleton.MESSAGE_EXTRA_SUBNAME);
            String changeType =
            bundle.getString(DDPStateSingleton.MESSAGE_EXTRA_CHANGETYPE);
            String docId = bundle.getString(DDPStateSingleton.MESSAGE_EXTRA_CHANGEID);
            onSubscriptionUpdate(changeType, subscriptionName, docId);
        }
    }
773228
public static Intent shareText(String subject, String text) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        if (!TextUtils.isEmpty(subject)) {
            intent.putExtra(Intent.EXTRA_SUBJECT, subject);
        }
        intent.putExtra(Intent.EXTRA_TEXT, text);
        intent.setType("text/plain");
        return intent;
    }
979473
def send_messages(self, request, queryset, bulk=False):
		
		ret = []
		errors = []
		r = ""

		for device in queryset:
			try:
				if bulk:
					r = queryset.send_message("Test bulk notification")
				else:
					r = device.send_message("Test single notification")
				if r:
					ret.append(r)
			except GCMError as e:
				errors.append(str(e))
			except APNSServerError as e:
				errors.append(e.status)
			except WebPushError as e:
				errors.append(e.message)

			if bulk:
				break

		# Because NotRegistered and InvalidRegistration do not throw GCMError
		# catch them here to display error msg.
		if not bulk:
			for r in ret:
				if "error" in r["results"][0]:
					errors.append(r["results"][0]["error"])
		else:
			try:
				errors = [r["error"] for r in ret[0][0]["results"] if "error" in r]
			except TypeError:
				for entry in ret[0][0]:
					errors = errors + [r["error"] for r in entry["results"] if "error" in r]
			except IndexError:
				pass
		if errors:
			self.message_user(
				request, _("Some messages could not be processed: %r" % (", ".join(errors))),
				level=messages.ERROR
			)
		if ret:
			if bulk:
				# When the queryset exceeds the max_recipients value, the
				# send_message method returns a list of dicts, one per chunk
				try:
					success = ret[0][0]["success"]
				except TypeError:
					success = 0
					for entry in ret[0][0]:
						success = success + entry["success"]
				if success == 0:
					return
			elif len(errors) == len(ret):
				return
			if errors:
				msg = _("Some messages were sent: %s" % (ret))
			else:
				msg = _("All messages were sent: %s" % (ret))
			self.message_user(request, msg)
173421
int getResponseCodeFromIntent(Intent i) {
        Object o = i.getExtras().get(RESPONSE_CODE);
        if (o == null) {
            logError("Intent with no response code, assuming OK (known issue)");
            return BILLING_RESPONSE_RESULT_OK;
        }
        else if (o instanceof Integer) return ((Integer)o).intValue();
        else if (o instanceof Long) return (int)((Long)o).longValue();
        else {
            logError("Unexpected type for intent response code.");
            logError(o.getClass().getName());
            throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
        }
    }
1147527
def onReceive(context, reload_intent)
      Log.d "Got reload intent: #{reload_intent.inspect}"
      file_string = reload_intent.get_string_extra('reload')
      if file_string
        scripts_dir = @activity.getExternalFilesDir(nil).absolute_path + '/scripts'
        files = file_string.split(/(?<!&);/).map { |f| f.gsub(/&(.)/) { |m| m[1] } }
        with_large_stack(size: 256) do
          files.each do |file|
            Log.d "load file: #{scripts_dir}/#{file}"
            load "#{scripts_dir}/#{file}"
          end
        end
        Log.d 'restart activity'
        if @activity.intent.action == android.content.Intent::ACTION_MAIN ||
            @activity.intent.action == android.hardware.usb.UsbManager::ACTION_USB_DEVICE_ATTACHED
          restart_intent = android.content.Intent.new(@activity.intent).
              setAction(android.content.Intent::ACTION_VIEW)
        else
          restart_intent = @activity.intent
        end
        @activity.finish
        @activity.startActivity(restart_intent)
        Log.d 'activity restarted'
      end
      Log.d 'reload complete.'
      true
    rescue Exception => e
      Log.e "Exception handling reload broadcast: #{e.message}"
      Log.e e.backtrace.join("\n")
    end
81540
private void encodeContentsFromZXingIntent(Intent intent) {
     // Default to QR_CODE if no format given.
    String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
    format = null;
    if (formatString != null) {
      try {
        format = BarcodeFormat.valueOf(formatString);
      } catch (IllegalArgumentException iae) {
        // Ignore it then
      }
    }
    if (format == null || format == BarcodeFormat.QR_CODE) {
      String type = intent.getStringExtra(Intents.Encode.TYPE);
      if (type != null && !type.isEmpty()) {
        this.format = BarcodeFormat.QR_CODE;
        encodeQRCodeContents(intent, type);
      }
    } else {
      String data = intent.getStringExtra(Intents.Encode.DATA);
      if (data != null && !data.isEmpty()) {
        contents = data;
        displayContents = data;
        title = activity.getString(R.string.contents_text);
      }
    }
  }
821340
public static void sendActionNoWait(final ManagerAction action)
    {
        final Thread background = new Thread()
        {
            @Override
            public void run()
            {
                try
                {
                    CoherentManagerConnection.sendAction(action, 5000);
                }
                catch (final Exception e)
                {
                    CoherentManagerConnection.logger.error(e, e);
                }
            }
        };
        background.setName("sendActionNoWait"); //$NON-NLS-1$
        background.setDaemon(true);
        background.start();
    }
306738
public static Bundle getAppLinkExtras(Intent intent) {
    Bundle appLinkData = getAppLinkData(intent);
    if (appLinkData == null) {
      return null;
    }
    return appLinkData.getBundle(KEY_NAME_EXTRAS);
  }
833685
@NonNull
    public Intent build() {
        Uri mailtoUri = constructMailtoUri();
        return new Intent(Intent.ACTION_SENDTO, mailtoUri);
    }
1298502
public final void startActivityForResult(@NonNull final Intent intent, final int requestCode, @Nullable final Bundle options) {
        executeWithRouter(new RouterRequiringFunc() {
            @Override public void execute() { router.startActivityForResult(instanceId, intent, requestCode, options); }
        });
    }
696043
public  void  execute() throws ActivityException{
        isSynchronized = checkIfSynchronized();
        if (!isSynchronized) {
            EventWaitInstance received = registerWaitEvents(false, true);
            if (received!=null)
                resume(getExternalEventInstanceDetails(received.getMessageDocumentId()), received.getCompletionCode());
        }
    }
1252033
def _map_intent_to_view_func(self, intent):
        """"""
        if intent.name in self._intent_view_funcs:
            view_func = self._intent_view_funcs[intent.name]
        elif self._default_intent_view_func is not None:
            view_func = self._default_intent_view_func
        else:
            raise NotImplementedError('Intent "{}" not found and no default intent specified.'.format(intent.name))

        PY3 = sys.version_info[0] == 3
        if PY3:
            argspec = inspect.getfullargspec(view_func)
        else:
            argspec = inspect.getargspec(view_func)
            
        arg_names = argspec.args
        arg_values = self._map_params_to_view_args(intent.name, arg_names)

        return partial(view_func, *arg_values)
896133
def dispatch(self):
        """"""

        if self.request.request.type == 'IntentRequest':
            name = self.request.request.intent.name
        else:
            name = self.request.request.type

        if name in self.logic:
            self.logic[name]()
        else:
            error = 'Unable to find a registered logic function named: {}'
            raise KeyError(error.format(name))
58550
function send () {
      sent = true;
      // next tick it to avoid express catching runtime error in the callback
      //   getting caught by express and triggering app's error handler
      process.nextTick(function () {
        res.emit('finish');
        cb(null, res, body);
      });
    }
586063
public void setIntents(java.util.Collection<Intent> intents) {
        if (intents == null) {
            this.intents = null;
            return;
        }

        this.intents = new java.util.ArrayList<Intent>(intents);
    }