3

I've built an app that reads out certain data from the student ID cards our school uses. Right now it only reads user data but in the future the plan is to add support to read the remaining credit.

The problem is that the cards we use are Mifare Classic. Nexus 4 and Nexus 10 (and possibly more devices) don't support these cards since they have a Broadcom NFC controller. If I'm right the app shouldn't crash or give issues on those devices, but it just doesn't do anything.

Is there a way to somehow exclude these devices without NXP controller? (Basically like uses-feature required for the MifareClassic class.) I can exclude the Nexus 4 and 10 through the Play Store but that's hardly a good solution - even more because other devices might start using Broadcom controllers and they'd all have to be excluded manually.

Thanks! - Ambroos

Ambroos
  • 3,456
  • 20
  • 27

2 Answers2

4

You can check in your app for MIFARE Classic support as follows:

boolean hasMifare(Context ctx) {
 return ctx.getPackageManager().hasSystemFeature("com.nxp.mifare");
}

There is no way to check for this before installing the app. But after installation, you can warn the user that the functionality of your app will be limited, because of the lack of MIFARE Classic support.

NFC guy
  • 10,151
  • 3
  • 27
  • 58
  • 4
    Thanks a lot! Turns out you CAN check this before installing (through the Play Store) by adding this to your manifest: `` – Ambroos Apr 06 '13 at 19:22
0

Apparently, the UID can still be read by those phones.

Can NFC Mifare Classic Tags be used at all with the Nexus 4 and 10?

YES! And no. While Mifare Classic Chips can not be written to or fully read by the Nexus 4 or 10, their UID (a unique identification code) can be detected and read. So Mifare Classic Chips can be used with the Nexus 4 or 10 along with an app such as AutomateIt which simply uses a tag's UID to trigger events/settings saved on the device. (ReTag & NFC Task Launcher also can just use a tag's UID but also have the ability to write to writable tags.) The down side to this is that because the tag can not be written to, if you have more than one of these types of NFC apps on your phone, tapping the tag will bring up a box to ask you what app you want to use. But if you only use one NFC app for all your Tag Events/Settings/etc., then this is not a problem and would allow you to make use of Mifare Classic tags for this purpose.

Read more at http://andytags.com/nfc-tags-nexus-4--10-compatibility.html#47A4kbkkGceGqe3L.99

I'd suggest you try to use the same principles that are used in progressive web enhancements programming, and use guard conditions wrapped inside of try/catch blocks to guard against each small function/assumption instead of filtering based on a name/brand only.

This way, if some manufacturer creates faulty tags, or if the user tries to scan two tags at the same time by mistake, or if a user removes the phone too quickly before a scan is complete, or whatever else happens in the future, your application will be able to cope more readily with those types of error conditions.

Stephan Branczyk
  • 9,363
  • 2
  • 33
  • 49
  • I use that to handle my exceptions already, but the point is that this app is specific to a single card type, I'd like for a way (other than manually excluding them) to make the right devices appear as incompatible. – Ambroos Apr 02 '13 at 23:46
  • And yet, you'd still be able to derive their student id through it. You just wouldn't be able to authenticate them, or know their balance. That kind of functionality could still be useful for some use cases thought. – Stephan Branczyk Apr 02 '13 at 23:54
  • I've checked, but all our cards' UIDs are random. The UID has no relation to the actual data that's on it so I can't really do anything with it... – Ambroos Apr 03 '13 at 16:00
  • Of course they are, but that doesn't mean your application can't do a lookup in a central database. – Stephan Branczyk Apr 03 '13 at 16:33
  • I think those Mifare cards will be taken out of circulation before our IT team is willing to code an API for that. – Ambroos Apr 03 '13 at 16:54
  • Yeah, forget I said anything. This is not something that you should do anyway. Some student on your campus will probably just end up creating an online database that allows each student to associate their Twitter ID, or something else with that existing UID. That's the kind of thing that usually ends up happening anyway. – Stephan Branczyk Apr 03 '13 at 17:06