private Address getAddressFromPrimaryClip() { if (!clipboardManager.hasPrimaryClip()) return null; final ClipData clip = clipboardManager.getPrimaryClip(); final ClipDescription clipDescription = clip.getDescription(); if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { final CharSequence clipText = clip.getItemAt(0).getText(); if (clipText == null) return null; try { return new Address(Constants.NETWORK_PARAMETERS, clipText.toString().trim()); } catch (final AddressFormatException x) { return null; } } else if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_URILIST)) { final Uri clipUri = clip.getItemAt(0).getUri(); if (clipUri == null) return null; try { return new BitcoinURI(clipUri.toString()).getAddress(); } catch (final BitcoinURIParseException x) { return null; } } else { return null; } }
boolean processDragStarted(DragEvent event) { // Determine whether to continue processing drag and drop based on the // plain text mime type. ClipDescription clipDesc = event.getClipDescription(); if (clipDesc != null) { return clipDesc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN); } return false; }
/** * Get the remote input results bundle from an intent. The returned Bundle will contain a * key/value for every result key populated by remote input collector. Use the {@link * Bundle#getCharSequence(String)} method to retrieve a value. * * @param intent The intent object that fired in response to an action or content intent which * also had one or more remote input requested. */ public static Bundle getResultsFromIntent(Intent intent) { ClipData clipData = intent.getClipData(); if (clipData == null) { return null; } ClipDescription clipDescription = clipData.getDescription(); if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) { return null; } if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) { return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA); } return null; }
public final Bundle getResultsFromIntent(Intent paramIntent) { paramIntent = paramIntent.getClipData(); if (paramIntent != null) { ClipDescription localClipDescription = paramIntent.getDescription(); if ((localClipDescription.hasMimeType("text/vnd.android.intent")) && (localClipDescription.getLabel().equals("android.remoteinput.results"))) { return (Bundle) paramIntent .getItemAt(0) .getIntent() .getExtras() .getParcelable("android.remoteinput.resultsData"); } } return null; }