i.normalizeMimeType(mimetype);
i.normalizeMimeType(mimetype);
/** * Map this record to a MIME type, or return null if it cannot be mapped.<p> * Currently this method considers all {@link #TNF_MIME_MEDIA} records to * be MIME records, as well as some {@link #TNF_WELL_KNOWN} records such as * {@link #RTD_TEXT}. If this is a MIME record then the MIME type as string * is returned, otherwise null is returned.<p> * This method does not perform validation that the MIME type is * actually valid. It always attempts to * return a string containing the type if this is a MIME record.<p> * The returned MIME type will by normalized to lower-case using * {@link Intent#normalizeMimeType}.<p> * The MIME payload can be obtained using {@link #getPayload}. * * @return MIME type as a string, or null if this is not a MIME record */ public String toMimeType() { switch (mTnf) { case NdefRecord.TNF_WELL_KNOWN: if (Arrays.equals(mType, NdefRecord.RTD_TEXT)) { return "text/plain"; } break; case NdefRecord.TNF_MIME_MEDIA: String mimeType = new String(mType, Charset.forName("US-ASCII")); return Intent.normalizeMimeType(mimeType); } return null; }
mimeType = Intent.normalizeMimeType(mimeType); if (mimeType.length() == 0) throw new IllegalArgumentException("mimeType is empty"); int slashIndex = mimeType.indexOf('/');