List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java
/** * ?./*from w w w . j a va 2s . c o m*/ * * @param mediaid ID */ public void notifyTakePhoto(final String mediaid) { for (String key : mOnPhotoCallback.keySet()) { Intent response = mOnPhotoCallback.get(key); ComponentName receiver = (ComponentName) response.getParcelableExtra("receiver"); Bundle photo = new Bundle(); photo.putString("mediaid", mediaid); photo.putString("mimetype", "image/png"); Intent intent = new Intent(); intent.setAction(IntentDConnectMessage.ACTION_EVENT); intent.setComponent(receiver); intent.putExtra("deviceid", "me"); intent.putExtra("profile", "mediastream_recording"); intent.putExtra("callback", "onphoto"); intent.putExtra("session_key", key); intent.putExtra("photo", photo); sendBroadcast(intent); } }
From source file:com.sftoolworks.nfcoptions.SelectActivity.java
protected void writeSelection(Intent intent) { ListView list = (ListView) findViewById(R.id.listView1); if (list.getCount() == 0) return;//from w w w .ja v a 2s. c o m try { Object[] results = ((OptionListAdapter) list.getAdapter()).getCheckedValues(); JSONObject obj = new JSONObject(); JSONArray array = new JSONArray(); if (null != results) { for (Object result : results) array.put(result.toString()); } obj.put("selection", array); obj.put("key", selectKey); SharedPreferences sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); // android studio (0.5.1) decorates this line as an error (some // of the time, anyway) but it's not an error. String identifier = sharedPref.getString(getString(R.string.user_id_key), ""); if (identifier.length() > 0) obj.put("user", identifier); String json = obj.toString(0); String outbound = "\u0002en"; outbound += json; NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, new byte[] { 'T' }, null, outbound.getBytes()); NdefMessage message = new NdefMessage(new NdefRecord[] { textRecord }); Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); Ndef ndef = Ndef.get(tag); ndef.connect(); ndef.writeNdefMessage(message); ndef.close(); Toast.makeText(this, R.string.write_ok, Toast.LENGTH_LONG).show(); new Timer().schedule(new TimerTask() { @Override public void run() { finish(); } }, 1500); } catch (Exception e) { Log.d(TAG, e.toString()); String err = getString(R.string.tag_write_err) + "\n" + e.getMessage(); Toast.makeText(this, err, Toast.LENGTH_LONG).show(); } }
From source file:com.heneryh.aquanotes.ui.DbMaintOutletsFragment.java
public void reloadFromArguments(Bundle arguments) { // Teardown from previous arguments if (mCursor != null) { getActivity().stopManagingCursor(mCursor); mCursor = null;//from www. j a va 2 s . c o m } mCheckedPosition = -1; setListAdapter(null); mHandler.cancelOperation(SearchQuery._TOKEN); mHandler.cancelOperation(ControllersQuery._TOKEN); // Load new arguments final Intent intent = BaseActivity.fragmentArgumentsToIntent(arguments); //final Uri controllersUri = intent.getData(); final int controllerQueryToken; final Uri controllersUri = Controllers.CONTENT_URI; // not gettting from intent if (controllersUri == null) { return; } String[] projection; if (!AquaNotesDbContract.Vendors.isSearchUri(controllersUri)) { mAdapter = new ControllersAdapter(getActivity()); projection = ControllersQuery.PROJECTION; controllerQueryToken = ControllersQuery._TOKEN; } else { Log.d("DbMaintOutletsFragment/reloadFromArguments", "A search URL definitely gets passed in."); mAdapter = new SearchAdapter(getActivity()); projection = SearchQuery.PROJECTION; controllerQueryToken = SearchQuery._TOKEN; } setListAdapter(mAdapter); // Start background query to load controllers mHandler.startQuery(controllerQueryToken, null, controllersUri, projection, null, null, AquaNotesDbContract.Controllers.DEFAULT_SORT); // If caller launched us with specific track hint, pass it along when // launching vendor details. Also start a query to load the track info. mTrackUri = intent.getParcelableExtra(SessionDetailFragment.EXTRA_TRACK); if (mTrackUri != null) { mHandler.startQuery(TracksQuery._TOKEN, mTrackUri, TracksQuery.PROJECTION); } }
From source file:reportsas.com.formulapp.Formulario.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (data != null) { if (data.hasExtra("data")) { Bitmap photobmp = (Bitmap) data.getParcelableExtra("data"); // iv.setImageBitmap(photobmp); ByteArrayOutputStream baos = new ByteArrayOutputStream(); photobmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); if (parametroCam == null) { parametroCam = new ParametrosRespuesta(2); }/*from w w w . jav a2 s .co m*/ parametroCam.setValor(encodedImage); // prueba.setText(encodedImage); // new MyAsyncTask(Formulario.this) // .execute("POST",encodedImage, HTTP_EVENT); } } } if (requestCode == MY_REQUEST_CODE && resultCode == Pdf417ScanActivity.RESULT_OK) { // First, obtain scan results array. If scan was successful, array will contain at least one element. // Multiple element may be in array if multiple scan results from single image were allowed in settings. Parcelable[] resultArray = data .getParcelableArrayExtra(Pdf417ScanActivity.EXTRAS_RECOGNITION_RESULT_LIST); StringBuilder sb = new StringBuilder(); for (Parcelable p : resultArray) { if (p instanceof Pdf417ScanResult) { // check if scan result is result of Pdf417 recognizer Pdf417ScanResult result = (Pdf417ScanResult) p; // getStringData getter will return the string version of barcode contents String barcodeData = result.getStringData(); // isUncertain getter will tell you if scanned barcode contains some uncertainties boolean uncertainData = result.isUncertain(); // getRawData getter will return the raw data information object of barcode contents BarcodeDetailedData rawData = result.getRawData(); // BarcodeDetailedData contains information about barcode's binary layout, if you // are only interested in raw bytes, you can obtain them with getAllData getter byte[] rawDataBuffer = rawData.getAllData(); DataR = rawData.toString(); String[] arrayElements = DataR.split("Element #"); String Nombre = "", Apellido = "", cedula = "", fecha = "", dia, mes, ano; if (arrayElements.length >= 7) { String[] auxliarArray = arrayElements[7].split("decoded\\):"); String strDatos = auxliarArray[1]; char[] ca = strDatos.toCharArray(); for (int i = 0; i < strDatos.length(); i++) { if (Character.isLetter(ca[i])) //Si es letra Apellido += ca[i]; //Salto de lnea e imprimimos el carcter else //Si no es letra cedula += ca[i]; //Imprimimos el carcter } Apellido = Apellido.trim(); cedula = (cedula.replaceAll("\n", "")).trim(); if (cedula.length() == 0) { auxliarArray = arrayElements[5].split("decoded\\):"); strDatos = auxliarArray[1]; ca = strDatos.toCharArray(); Apellido = ""; for (int i = 0; i < strDatos.length(); i++) { if (Character.isLetter(ca[i])) //Si es letra Apellido += ca[i]; //Salto de lnea e imprimimos el carcter else //Si no es letra cedula += ca[i]; //Imprimimos el carcter } Apellido = Apellido.trim(); cedula = (cedula.replaceAll("\n", "")).trim(); cedula = cedula.substring(cedula.length() - 10, cedula.length()); cedula = eliminarceros(cedula); auxliarArray = arrayElements[9].split("decoded\\):"); Nombre = (auxliarArray[1].replaceAll("\n", "")).trim(); } else { cedula = eliminarceros(cedula); auxliarArray = arrayElements[11].split("decoded\\):"); Nombre = (auxliarArray[1].replaceAll("\n", "")).trim(); } auxliarArray = result.getStringData().toString().split(Nombre); strDatos = auxliarArray[1]; ca = strDatos.toCharArray(); Boolean result_ciclo = true; int i = 0; while (result_ciclo) { if (Character.isDigit(ca[i])) { fecha += ca[i]; } if (fecha.length() >= 9) { result_ciclo = false; } i++; } fecha = fecha.substring(1, fecha.length()); } else { int puntoI = 0; if (barcodeData.indexOf("1F") > 0) { puntoI = barcodeData.indexOf("1F"); } else if (barcodeData.indexOf("0M") > 0) { puntoI = barcodeData.indexOf("0M"); } else if (barcodeData.indexOf("0F") > 0) { puntoI = barcodeData.indexOf("0F"); } else if (barcodeData.indexOf("1M") > 0) { puntoI = barcodeData.indexOf("1M"); } else { } if (puntoI > 0) { String seb = barcodeData.substring(1, puntoI); fecha = barcodeData.substring(puntoI + 2, puntoI + 10); int posL = 0, posE; char[] ca = seb.toCharArray(); for (int w = seb.length() - 1; w > 0; w--) { if (Character.isLetter(ca[w])) { posL = w; break; } } seb = seb.substring(1, posL + 1); ca = seb.toCharArray(); for (int w = seb.length() - 1; w > 0; w--) { if (Character.isLetter(ca[w])) { Nombre = ca[w] + Nombre; posL = w; } else { break; } } seb = seb.substring(1, posL); ca = seb.toCharArray(); for (int w = seb.length() - 1; w > 0; w--) { if (Character.isDigit(ca[w])) { posL = w; break; } } for (int w = posL + 1; w <= seb.length(); w++) { if (Character.isLetter(ca[w])) { Apellido += ca[w]; } else { break; } } cedula = seb.substring(posL - 9, posL + 1); cedula = eliminarceros(cedula); } else { fecha = ""; } } if (fecha.length() == 0) { parametroScan = null; Toast toast1 = Toast.makeText(this, "Los datos de codigo no pudieron ser interpretados!", Toast.LENGTH_SHORT); toast1.show(); } else { dia = fecha.substring(6, 8); mes = fecha.substring(4, 6); ano = fecha.substring(0, 4); fecha = dia + "/" + mes + "/" + ano; Infocadena = "Nombre: \n" + Nombre + ".\nApellido: \n" + Apellido + ". \nCedula: \n" + cedula + ". \nFecha de Nacimiento: \n" + fecha + "."; if (parametroScan == null) { parametroScan = new ParametrosRespuesta(3); } parametroScan.setValor(Infocadena); } // new MyAsyncTask(Formulario.this) // .execute("POST",Infocadena, HTTP_EVENT); } else if (p instanceof BarDecoderScanResult) { // check if scan result is result of BarDecoder recognizer /* BarDecoderScanResult result = (BarDecoderScanResult) p; // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode BarcodeType type = result.getBarcodeType(); // as with PDF417, getStringData will return the string contents of barcode String barcodeData = result.getStringData(); if(checkIfDataIsUrlAndCreateIntent(barcodeData)) { return; } else { sb.append(type.name()); sb.append(" string data:\n"); sb.append(barcodeData); sb.append("\n\n\n");= }*/ } else if (p instanceof ZXingScanResult) { // check if scan result is result of ZXing recognizer /* ZXingScanResult result= (ZXingScanResult) p; // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode BarcodeType type = result.getBarcodeType(); // as with PDF417, getStringData will return the string contents of barcode String barcodeData = result.getStringData(); if(checkIfDataIsUrlAndCreateIntent(barcodeData)) { return; } else { sb.append(type.name()); sb.append(" string data:\n"); sb.append(barcodeData); sb.append("\n\n\n"); }*/ } else if (p instanceof USDLScanResult) { // check if scan result is result of US Driver's Licence recognizer USDLScanResult result = (USDLScanResult) p; // USDLScanResult can contain lots of information extracted from driver's licence // you can obtain information using the getField method with keys defined in // USDLScanResult class String name = result.getField(USDLScanResult.kCustomerFullName); sb.append(result.getTitle()); sb.append("\n\n"); sb.append(result.toString()); } } } }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
/** * Request the operation for copying the file/folder from one path to another * * @param data Intent received/*from w w w .j ava 2s . c o m*/ * @param resultCode Result code received */ private void requestCopyOperation(Intent data, int resultCode) { OCFile folderToMoveAt = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER); OCFile targetFile = data.getParcelableExtra(FolderPickerActivity.EXTRA_FILE); getFileOperationsHelper().copyFile(folderToMoveAt, targetFile); }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
/** * Request the operation for moving the file/folder from one path to another * * @param data Intent received//from w w w . j a v a 2 s . c o m * @param resultCode Result code received */ private void requestMoveOperation(Intent data, int resultCode) { OCFile folderToMoveAt = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER); OCFile targetFile = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_FILE); getFileOperationsHelper().moveFile(folderToMoveAt, targetFile); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * Creates new instance with {@link FileChooserActivity#ACTION_CHOOSE}. * //from w w w . j a v a 2 s . com * @param intent * the intent you got from {@link FileChooserActivity}. * @return the new instance of this fragment. */ public static FragmentFiles newInstance(Intent intent) { /* * Load the extras. */ final Bundle args = new Bundle(); for (String ex : EXTRAS_BOOLEAN) if (intent.hasExtra(ex)) args.putBoolean(ex, intent.getBooleanExtra(ex, false)); for (String ex : EXTRAS_INTEGER) if (intent.hasExtra(ex)) args.putInt(ex, intent.getIntExtra(ex, 0)); for (String ex : EXTRAS_PARCELABLE) if (intent.hasExtra(ex)) args.putParcelable(ex, intent.getParcelableExtra(ex)); for (String ex : EXTRAS_STRING) if (intent.hasExtra(ex)) args.putString(ex, intent.getStringExtra(ex)); return newInstance(args); }
From source file:edu.cmu.mpcs.dashboard.TagViewer.java
@Override public void onNewIntent(Intent intent) { setIntent(intent);// w w w. j a v a2 s. co m Log.d("TAG_VIEWER", "on new intent actually fired "); if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { resolveIntent(intent); } // Tag writing mode if (writeContent != null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Log.d("TAG_VIEWER", "in Oncreate Before writing"); // new AlertDialog.Builder(TagViewer.this) // .setTitle("Touch tag to write") // .setOnCancelListener( // new DialogInterface.OnCancelListener() { // public void onCancel(DialogInterface dialog) { // disableTagWriteMode(); // // } // }).create().show(); Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); try { WriteToTag.write(detectedTag, writeContent); Context context = getApplicationContext(); CharSequence text = "Tag sucessfully written!!"; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.show(); Log.d("TAG_VIEWER", "Before calling dialog.cancel"); dialog.dismiss(); finish(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("TAG_VIEWER", "in on create, writing to tag"); } // // // Tag writing mode // if (mWriteMode // && // NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) // { // Tag detectedTag = // intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); // try { // WriteToTag.write(detectedTag); // } catch (IOException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } catch (FormatException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // Log.d("TAG_VIEWER", "in on new intent, writing to tag"); // } }
From source file:com.android.contacts.ContactSaveService.java
private void deleteContact(Intent intent) { Uri contactUri = intent.getParcelableExtra(EXTRA_CONTACT_URI); if (contactUri == null) { Log.e(TAG, "Invalid arguments for deleteContact request"); return;//from w w w . j a va 2 s . co m } getContentResolver().delete(contactUri, null, null); }
From source file:com.android.contacts.ContactSaveService.java
private void setRingtone(Intent intent) { Uri contactUri = intent.getParcelableExtra(EXTRA_CONTACT_URI); String value = intent.getStringExtra(EXTRA_CUSTOM_RINGTONE); if (contactUri == null) { Log.e(TAG, "Invalid arguments for setRingtone"); return;//from w w w . j a v a2s . c o m } ContentValues values = new ContentValues(1); values.put(Contacts.CUSTOM_RINGTONE, value); getContentResolver().update(contactUri, values, null, null); }