use of android.nfc.TagLostException in project android_frameworks_base by DirtyUnicorns.
the class Ndef method getNdefMessage.
/**
* Read the current {@link android.nfc.NdefMessage} on this tag.
*
* <p>This always reads the current NDEF Message stored on the tag.
*
* <p>Note that this method may return null if the tag was in the
* INITIALIZED state as defined by NFC Forum, as in that state the
* tag is formatted to support NDEF but does not contain a message yet.
*
* <p>This is an I/O operation and will block until complete. It must
* not be called from the main application thread. A blocked call will be canceled with
* {@link IOException} if {@link #close} is called from another thread.
*
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
*
* @return the NDEF Message, can be null
* @throws TagLostException if the tag leaves the field
* @throws IOException if there is an I/O failure, or the operation is canceled
* @throws FormatException if the NDEF Message on the tag is malformed
*/
public NdefMessage getNdefMessage() throws IOException, FormatException {
checkConnected();
try {
INfcTag tagService = mTag.getTagService();
if (tagService == null) {
throw new IOException("Mock tags don't support this operation.");
}
int serviceHandle = mTag.getServiceHandle();
if (tagService.isNdef(serviceHandle)) {
NdefMessage msg = tagService.ndefRead(serviceHandle);
if (msg == null && !tagService.isPresent(serviceHandle)) {
throw new TagLostException();
}
return msg;
} else if (!tagService.isPresent(serviceHandle)) {
throw new TagLostException();
} else {
return null;
}
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return null;
}
}
use of android.nfc.TagLostException in project android_frameworks_base by ResurrectionRemix.
the class Ndef method getNdefMessage.
/**
* Read the current {@link android.nfc.NdefMessage} on this tag.
*
* <p>This always reads the current NDEF Message stored on the tag.
*
* <p>Note that this method may return null if the tag was in the
* INITIALIZED state as defined by NFC Forum, as in that state the
* tag is formatted to support NDEF but does not contain a message yet.
*
* <p>This is an I/O operation and will block until complete. It must
* not be called from the main application thread. A blocked call will be canceled with
* {@link IOException} if {@link #close} is called from another thread.
*
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
*
* @return the NDEF Message, can be null
* @throws TagLostException if the tag leaves the field
* @throws IOException if there is an I/O failure, or the operation is canceled
* @throws FormatException if the NDEF Message on the tag is malformed
*/
public NdefMessage getNdefMessage() throws IOException, FormatException {
checkConnected();
try {
INfcTag tagService = mTag.getTagService();
if (tagService == null) {
throw new IOException("Mock tags don't support this operation.");
}
int serviceHandle = mTag.getServiceHandle();
if (tagService.isNdef(serviceHandle)) {
NdefMessage msg = tagService.ndefRead(serviceHandle);
if (msg == null && !tagService.isPresent(serviceHandle)) {
throw new TagLostException();
}
return msg;
} else if (!tagService.isPresent(serviceHandle)) {
throw new TagLostException();
} else {
return null;
}
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return null;
}
}
use of android.nfc.TagLostException in project android_frameworks_base by ParanoidAndroid.
the class Ndef method getNdefMessage.
/**
* Read the current {@link android.nfc.NdefMessage} on this tag.
*
* <p>This always reads the current NDEF Message stored on the tag.
*
* <p>Note that this method may return null if the tag was in the
* INITIALIZED state as defined by NFC Forum, as in that state the
* tag is formatted to support NDEF but does not contain a message yet.
*
* <p>This is an I/O operation and will block until complete. It must
* not be called from the main application thread. A blocked call will be canceled with
* {@link IOException} if {@link #close} is called from another thread.
*
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
*
* @return the NDEF Message, can be null
* @throws TagLostException if the tag leaves the field
* @throws IOException if there is an I/O failure, or the operation is canceled
* @throws FormatException if the NDEF Message on the tag is malformed
*/
public NdefMessage getNdefMessage() throws IOException, FormatException {
checkConnected();
try {
INfcTag tagService = mTag.getTagService();
if (tagService == null) {
throw new IOException("Mock tags don't support this operation.");
}
int serviceHandle = mTag.getServiceHandle();
if (tagService.isNdef(serviceHandle)) {
NdefMessage msg = tagService.ndefRead(serviceHandle);
if (msg == null && !tagService.isPresent(serviceHandle)) {
throw new TagLostException();
}
return msg;
} else {
return null;
}
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return null;
}
}
use of android.nfc.TagLostException in project platform_frameworks_base by android.
the class Ndef method getNdefMessage.
/**
* Read the current {@link android.nfc.NdefMessage} on this tag.
*
* <p>This always reads the current NDEF Message stored on the tag.
*
* <p>Note that this method may return null if the tag was in the
* INITIALIZED state as defined by NFC Forum, as in that state the
* tag is formatted to support NDEF but does not contain a message yet.
*
* <p>This is an I/O operation and will block until complete. It must
* not be called from the main application thread. A blocked call will be canceled with
* {@link IOException} if {@link #close} is called from another thread.
*
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
*
* @return the NDEF Message, can be null
* @throws TagLostException if the tag leaves the field
* @throws IOException if there is an I/O failure, or the operation is canceled
* @throws FormatException if the NDEF Message on the tag is malformed
*/
public NdefMessage getNdefMessage() throws IOException, FormatException {
checkConnected();
try {
INfcTag tagService = mTag.getTagService();
if (tagService == null) {
throw new IOException("Mock tags don't support this operation.");
}
int serviceHandle = mTag.getServiceHandle();
if (tagService.isNdef(serviceHandle)) {
NdefMessage msg = tagService.ndefRead(serviceHandle);
if (msg == null && !tagService.isPresent(serviceHandle)) {
throw new TagLostException();
}
return msg;
} else if (!tagService.isPresent(serviceHandle)) {
throw new TagLostException();
} else {
return null;
}
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return null;
}
}
use of android.nfc.TagLostException in project android_frameworks_base by AOSPA.
the class Ndef method getNdefMessage.
/**
* Read the current {@link android.nfc.NdefMessage} on this tag.
*
* <p>This always reads the current NDEF Message stored on the tag.
*
* <p>Note that this method may return null if the tag was in the
* INITIALIZED state as defined by NFC Forum, as in that state the
* tag is formatted to support NDEF but does not contain a message yet.
*
* <p>This is an I/O operation and will block until complete. It must
* not be called from the main application thread. A blocked call will be canceled with
* {@link IOException} if {@link #close} is called from another thread.
*
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
*
* @return the NDEF Message, can be null
* @throws TagLostException if the tag leaves the field
* @throws IOException if there is an I/O failure, or the operation is canceled
* @throws FormatException if the NDEF Message on the tag is malformed
*/
public NdefMessage getNdefMessage() throws IOException, FormatException {
checkConnected();
try {
INfcTag tagService = mTag.getTagService();
if (tagService == null) {
throw new IOException("Mock tags don't support this operation.");
}
int serviceHandle = mTag.getServiceHandle();
if (tagService.isNdef(serviceHandle)) {
NdefMessage msg = tagService.ndefRead(serviceHandle);
if (msg == null && !tagService.isPresent(serviceHandle)) {
throw new TagLostException();
}
return msg;
} else if (!tagService.isPresent(serviceHandle)) {
throw new TagLostException();
} else {
return null;
}
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return null;
}
}
Aggregations