List of usage examples for android.content Intent getByteArrayExtra
public byte[] getByteArrayExtra(String name)
From source file:at.flack.MainActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { // QR Code Activity (return QR code from scan) if (resultCode == RESULT_OK) { if (data.getByteArrayExtra("QR_RETURNED_Bytes") != null) { new HandshakeProcessor(this).processReceivedExchangeInformation(data, this, ""); }/*from w w w. j ava 2s . c om*/ } } }
From source file:se.anyro.nfc_reader.TagViewer.java
private void resolveIntent(Intent intent) { String action = intent.getAction(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage[] msgs;/*from ww w .ja va 2s . c om*/ if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; // magic happens here processReadTag((NdefMessage) rawMsgs[i]); } } else { // Unknown tag type byte[] empty = new byte[0]; byte[] id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); Parcelable tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); byte[] payload = dumpTagData(tag).getBytes(); NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, id, payload); NdefMessage msg = new NdefMessage(new NdefRecord[] { record }); msgs = new NdefMessage[] { msg }; } // Setup the views buildTagViews(msgs); } }
From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void resolveUndoAction(Intent intent) { if (!intent.hasExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION)) { return;// ww w .j av a2 s . c om } /* * Grab the alarm from the intent. Since the remote AlarmManagerService fills in the Intent to add some extra data, it must unparcel the * NotificationAction object. It throws a ClassNotFoundException when unparcelling. To avoid this, do the marshalling ourselves. */ final NotificationAction notificationAction; final String action = intent.getAction(); final byte[] data = intent.getByteArrayExtra(NotificationActionUtils.EXTRA_NOTIFICATION_ACTION); if (data != null) { final Parcel in = Parcel.obtain(); in.unmarshall(data, 0, data.length); in.setDataPosition(0); notificationAction = NotificationAction.CREATOR.createFromParcel(in); } else { return; } if (NotificationActionUtils.ACTION_UNDO.equals(action)) { NotificationActionUtils.cancelUndoTimeout(this, notificationAction); NotificationActionUtils.cancelUndoNotification(this, notificationAction); resendNotification(notificationAction); } else if (ACTION_COMPLETE.equals(action)) { // All we need to do is switch to an Undo notification NotificationActionUtils.createUndoNotification(this, notificationAction); NotificationActionUtils.registerUndoTimeout(this, notificationAction); } else { if (NotificationActionUtils.ACTION_UNDO_TIMEOUT.equals(action) || NotificationActionUtils.ACTION_DESTRUCT.equals(action)) { // Process the action NotificationActionUtils.cancelUndoTimeout(this, notificationAction); NotificationActionUtils.processUndoNotification(this, notificationAction); processDesctructiveNotification(notificationAction); } } }
From source file:net.kazzz.NFCTagReader.java
@Override public void onTagDiscovered(Intent intent, Parcelable nfcTag, AbstractNfcTagFragment fragment) { //TextView tv_tag = (TextView) findViewById(R.id.result_tv); Button btnRead = (Button) findViewById(R.id.btn_read); btnRead.setOnClickListener(this); Button btnHistory = (Button) findViewById(R.id.btn_hitory); btnHistory.setOnClickListener(this); btnHistory.setEnabled(false);//ww w .j a va2 s .c o m Button btnWrite = (Button) findViewById(R.id.btn_write); btnWrite.setOnClickListener(this); btnWrite.setEnabled(false); Button btnInout = (Button) findViewById(R.id.btn_inout); btnInout.setOnClickListener(this); btnInout.setEnabled(false); try { mLastFragment = fragment; //? if (mLastFragment instanceof NfcFeliCaTagFragment) { NfcFeliCaTagFragment nff = (NfcFeliCaTagFragment) mLastFragment; boolean isFeliCatLite = nff.isFeliCaLite(); try { FeliCaLib.IDm idm = new FeliCaLib.IDm(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID)); if (idm == null) { throw new FeliCaException("Felica IDm ?????????"); } btnHistory.setEnabled(!isFeliCatLite); btnWrite.setEnabled(isFeliCatLite); btnRead.performClick(); } catch (Exception e) { e.printStackTrace(); Log.e(TAG, e.toString()); } btnHistory.setEnabled(!isFeliCatLite); btnWrite.setEnabled(isFeliCatLite); } else { btnRead.performClick(); btnHistory.setEnabled(false); btnWrite.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); Log.e(TAG, e.toString()); } }
From source file:org.ounl.lifelonglearninghub.mediaplayer.cast.refplayer.NFCVideoBrowserActivity.java
/** * On create, process NDEF message with its intent action * /*from w w w .ja v a 2 s . co m*/ * @param intent */ private String resolveIntent(Intent intent) { Log.d(CLASSNAME, "resolveIntent is called intent:" + intent.toString()); String action = intent.getAction(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage[] msgs; if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } } else { // Unknown tag type byte[] empty = new byte[0]; byte[] id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); Parcelable tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); byte[] payload = dumpTagData(tag).getBytes(); NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, id, payload); NdefMessage msg = new NdefMessage(new NdefRecord[] { record }); msgs = new NdefMessage[] { msg }; } return processNdefMessageArray(msgs); } return IParsedNdefCommand.COMMAND_UNKNOWN; }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java
protected void handleActions(Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras();//from ww w.ja va 2s. co m if (extras == null) { extras = new Bundle(); } /** * Android Standard Actions */ if (Intent.ACTION_VIEW.equals(action)) { // Android's Action when opening file associated to APG (see AndroidManifest.xml) // override action to delegate it to APGs ACTION_IMPORT action = ACTION_IMPORT; } /** * APG's own Actions */ if (ACTION_IMPORT.equals(action)) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { mImportFilename = intent.getData().getPath(); mImportData = null; } else if (extras.containsKey(EXTRA_TEXT)) { mImportData = intent.getStringExtra(EXTRA_TEXT).getBytes(); mImportFilename = null; } else if (extras.containsKey(EXTRA_KEYRING_BYTES)) { mImportData = intent.getByteArrayExtra(EXTRA_KEYRING_BYTES); mImportFilename = null; } loadKeyListFragment(); } else if (ACTION_IMPORT_FROM_FILE.equals(action)) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { mImportFilename = intent.getData().getPath(); mImportData = null; } showImportFromFileDialog(); } else if (ACTION_IMPORT_FROM_QR_CODE.equals(action)) { importFromQrCode(); } else if (ACTION_IMPORT_FROM_NFC.equals(action)) { importFromNfc(); } }
From source file:com.fenlisproject.elf.core.framework.ElfBinder.java
public static void bindIntentExtra(Object receiver) { Field[] fields = receiver.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true);/*from w ww . ja v a 2 s .co m*/ IntentExtra intentExtra = field.getAnnotation(IntentExtra.class); if (intentExtra != null) { try { Intent intent = null; if (receiver instanceof Activity) { intent = ((Activity) receiver).getIntent(); } else if (receiver instanceof Fragment) { intent = ((Fragment) receiver).getActivity().getIntent(); } if (intent != null) { Class<?> type = field.getType(); if (type == Boolean.class || type == boolean.class) { field.set(receiver, intent.getBooleanExtra(intentExtra.value(), false)); } else if (type == Byte.class || type == byte.class) { field.set(receiver, intent.getByteExtra(intentExtra.value(), (byte) 0)); } else if (type == Character.class || type == char.class) { field.set(receiver, intent.getCharExtra(intentExtra.value(), '\u0000')); } else if (type == Double.class || type == double.class) { field.set(receiver, intent.getDoubleExtra(intentExtra.value(), 0.0d)); } else if (type == Float.class || type == float.class) { field.set(receiver, intent.getFloatExtra(intentExtra.value(), 0.0f)); } else if (type == Integer.class || type == int.class) { field.set(receiver, intent.getIntExtra(intentExtra.value(), 0)); } else if (type == Long.class || type == long.class) { field.set(receiver, intent.getLongExtra(intentExtra.value(), 0L)); } else if (type == Short.class || type == short.class) { field.set(receiver, intent.getShortExtra(intentExtra.value(), (short) 0)); } else if (type == String.class) { field.set(receiver, intent.getStringExtra(intentExtra.value())); } else if (type == Boolean[].class || type == boolean[].class) { field.set(receiver, intent.getBooleanArrayExtra(intentExtra.value())); } else if (type == Byte[].class || type == byte[].class) { field.set(receiver, intent.getByteArrayExtra(intentExtra.value())); } else if (type == Character[].class || type == char[].class) { field.set(receiver, intent.getCharArrayExtra(intentExtra.value())); } else if (type == Double[].class || type == double[].class) { field.set(receiver, intent.getDoubleArrayExtra(intentExtra.value())); } else if (type == Float[].class || type == float[].class) { field.set(receiver, intent.getFloatArrayExtra(intentExtra.value())); } else if (type == Integer[].class || type == int[].class) { field.set(receiver, intent.getIntArrayExtra(intentExtra.value())); } else if (type == Long[].class || type == long[].class) { field.set(receiver, intent.getLongArrayExtra(intentExtra.value())); } else if (type == Short[].class || type == short[].class) { field.set(receiver, intent.getShortArrayExtra(intentExtra.value())); } else if (type == String[].class) { field.set(receiver, intent.getStringArrayExtra(intentExtra.value())); } else if (Serializable.class.isAssignableFrom(type)) { field.set(receiver, intent.getSerializableExtra(intentExtra.value())); } else if (type == Bundle.class) { field.set(receiver, intent.getBundleExtra(intentExtra.value())); } } } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:org.kontalk.ui.NumberValidation.java
@Override @SuppressWarnings("unchecked") protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_MANUAL_VALIDATION) { if (resultCode == RESULT_OK) { Map<String, Keyring.TrustedFingerprint> trustedKeys = null; Map<String, String> keys = (HashMap) data.getSerializableExtra(PARAM_TRUSTED_KEYS); if (keys != null) { trustedKeys = Keyring.fromTrustedFingerprintMap(keys); }/*from w ww.j a va 2 s . com*/ finishLogin(data.getStringExtra(PARAM_SERVER_URI), data.getStringExtra(PARAM_CHALLENGE), data.getByteArrayExtra(PARAM_PRIVATEKEY), data.getByteArrayExtra(PARAM_PUBLICKEY), true, trustedKeys); } else if (resultCode == RESULT_FALLBACK) { mClearState = true; startValidation(data.getBooleanExtra("force", false), true); } } }
From source file:id.nci.stm_9.ImportKeysActivity.java
protected void handleActions(Bundle savedInstanceState, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras();//from www. ja v a 2s. co m if (extras == null) { extras = new Bundle(); } /** * Android Standard Actions */ if (Intent.ACTION_VIEW.equals(action)) { // Android's Action when opening file associated to Keychain (see AndroidManifest.xml) // override action to delegate it to Keychain's ACTION_IMPORT_KEY action = ACTION_IMPORT_KEY; } /** * Keychain's own Actions */ if (ACTION_IMPORT_KEY.equals(action)) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { String importFilename = intent.getData().getPath(); // display selected filename getSupportActionBar().setSelectedNavigationItem(0); Bundle args = new Bundle(); args.putString(ImportKeysFileFragment.ARG_PATH, importFilename); loadFragment(ImportKeysFileFragment.class, args, mNavigationStrings[0]); // directly load data startListFragment(savedInstanceState, null, importFilename); } else if (extras.containsKey(EXTRA_KEY_BYTES)) { byte[] importData = intent.getByteArrayExtra(EXTRA_KEY_BYTES); // directly load data startListFragment(savedInstanceState, importData, null); } } else { // Internal actions startListFragment(savedInstanceState, null, null); if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) { getSupportActionBar().setSelectedNavigationItem(0); loadFragment(ImportKeysFileFragment.class, null, mNavigationStrings[0]); } // } else if (ACTION_IMPORT_KEY_FROM_QR_CODE.equals(action)) { // getSupportActionBar().setSelectedNavigationItem(2); // loadFragment(ImportKeysQrCodeFragment.class, null, mNavigationStrings[2]); // } else if (ACTION_IMPORT_KEY_FROM_NFC.equals(action)) { // getSupportActionBar().setSelectedNavigationItem(3); // loadFragment(ImportKeysNFCFragment.class, null, mNavigationStrings[3]); // } } }