Fix NPE on devices that don't have NFC.
We should return null instead of NPE. Bug: 5622939 Change-Id: I802f4a99ea9f5e73453d5ea30da4e1d9fa279b9c
This commit is contained in:
@@ -360,6 +360,10 @@ public final class NfcAdapter {
|
||||
/* use getSystemService() instead of just instantiating to take
|
||||
* advantage of the context's cached NfcManager & NfcAdapter */
|
||||
NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
|
||||
if (manager == null) {
|
||||
// NFC not available
|
||||
return null;
|
||||
}
|
||||
return manager.getDefaultAdapter();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user