简体   繁体   中英

How to read a magnetic card in android

We are developing an android application where user can swipe his/her magnetic card.

We need to parse the information, however there will be two scenarios to capture and handle the card input (we have connected the USB magnetic card reader):

  1. When focus is on Credit Card# textbox and user swipes his/her card we need to parse the information, need to show the card number only in the current focus field and Card Holder Name in another textbox/label.

  2. If our application is running or even if it is not running and user swipes his/her card, we need to capture this information take the user to a particular activity in our application and need to pre-populate the captured information.

Please let us know how to do this in both scenarios.

The MSR100 is a fairly cheap USB HID device. You can get more information, including some setup info here:

http://www.posunitech.com/products_detail/&productId=73.html

I'm fairly certain you can use it like a standard keyboard on android by using a USB OTG cable. Not all devices can use it, but it will essentially let you use many USB devices on Android. With it, you can put your cursor in an EditText field and swipe to get the raw swipe data. From there you could write a listener on the EditText field to pull back the stripe, parse it, and put the data where you want.

If you want better security and less liability, I would go with an encrypted swiper that has EMV/Smart Card capability. IDTech has their UniPay models that do these and are compatible with PC, iOS, & Android.

http://www.idtechproducts.com/products/mobile-readers/176.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM