MiFare Classic detection

by androidom » Mon, 11 Apr 2011 04:39:54 GMT


Sponsored Links
 Hi there,
I used the sample code in my app to detect a Mifare Classic card.
My resource file looks like
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <tech-list>
        <tech>android.nfc.tech.NfcA</tech>
        <tech>android.nfc.tech.NfcB</tech>
        <tech>android.nfc.tech.NfcF</tech>
        <tech>android.nfc.tech.NfcV</tech>
        <tech>android.nfc.tech.Ndef</tech>
        <tech>android.nfc.tech.NdefFormatable</tech>
        <tech>android.nfc.tech.MifareClassic</tech>
    </tech-list>
</resources>

and my manifest has..

<activity android:name="verifytagscanact"
                android:permission="android.permission.NFC"
                android:label="@string/event_verify">
                <action android:name="android.nfc.action.TECH_DISCOVERED"/>
                <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
           android:resource="@xml/filter_nfc"/>
                </activity>

and the onCreate in the activity has the code..


                 Intent intent = getIntent();
                String action = intent.getAction();
                if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
                        mTagContent.setText("Discovered tag " + ++mCount + " 
with
intent: " + intent);
                } else {
                        mTagContent.setText("Scan a tag");
                }


But when I move a Mifare Classic 1k tag near the phone the "Tags"
application is called I think..as the icon on the top left is the same
as the app name..and the title is " New Tag collected- unknown tag
type ".

I am pretty sure the above activity is not called. Can someone guide
me how to get my application called when a tag is discovered.. ? it is
a Nexus S. phone with 2.3.1

thank you
Domnic

-- 



Re: MiFare Classic detection

by Michael Roland » Mon, 11 Apr 2011 15:08:12 GMT


 Hallo Domnic,


Right, this tech-list won't trigger on any tag. Take a look at the
documentation at [url] http://developer.android.com/reference/android/ 
nfc/NfcAdapter.html#ACTION_TECH_DISCOVERED[/url]. It says that <tech-
list> combines its <tech> entries with AND. So you are trying to
listen for a tag that is NfcA AND NfcB AND NfcF AND NfcV at the same
time. However a tag will only be detected as one RF technology.

To listen for multiple tag technologies you would need multiple <tech-
list> entries (they are then combined with logical OR.)

If you want to detect only MIFARE Classic, a filter like this would
suffice:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <tech-list>
        <tech>android.nfc.tech.MifareClassic</tech>
    </tech-list>
</resources>

Of course every MIFARE tag uses the RF technology NfcA, so a filter
like this will also work:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <tech-list>
        <tech>android.nfc.tech.NfcA</tech>
        <tech>android.nfc.tech.MifareClassic</tech>
    </tech-list>
</resources>

br,
Michael

-- 


Sponsored Links


Re: MiFare Classic detection

by androidom » Tue, 12 Apr 2011 21:08:45 GMT


 Dear  Michael,
Many thanks for your reply. I tried it,


But when I started my app and then brought the tag close.. I dont
think my app is getting called. some default app gets triggerd..
atleast it doest not land in my code when I set the debug point. The
screen comes up with the title  " New Tag collected- unknown tag
type ".

any suggestions on which app to de install or how to set priority to
my app ?
thanks
Domnic

-- 



Re: Re: MiFare Classic detection

by Michael Roland » Tue, 12 Apr 2011 21:30:52 GMT


 Hallo Domnic,

I've just re-read through the code you posted before and found another
problem:
Did you place the <action> inside an <intent-filter>?

Like this:

<intent-filter>
  <action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
           android:resource="@xml/filter_nfc" />


br
Michael

-- 



Re: MiFare Classic detection

by androidom » Wed, 13 Apr 2011 18:29:14 GMT


 Hello Michael,
I tried this with the intend filter. I am not getting my app
triggered. somehow it is still landing on the Tags app. and I am not
able to de.install the tags app.
do you have a working source which can just detect a tag and show up
the ID of the tag.. a Mifare classic one perhaps..?
thanks
Domnic

-- 



Re: MiFare Classic detection

by androidom » Wed, 13 Apr 2011 18:37:34 GMT


 Hi Michael,
Just another question, I would like to start scanning for a tag inside
an activity on press of a button say - "Start Scanning". In which
case, the scanning of the tag must be triggered after that button
press. Once a tag is scanned, then it must get the ID of the tag back
to the activity that started the scanning.

can you help me with a short description.. how I can reach this
perhaps..?
many thanks to you
Domnic

-- 



Re: Re: MiFare Classic detection

by Zaid Siryani » Wed, 13 Apr 2011 19:48:58 GMT


 I have created an RFID Message on my phone how can i read it on my PC
am using acr122






-- 
Best Regards
Zaid Siryani

-- 



Re: Re: MiFare Classic detection

by Michael Roland » Wed, 13 Apr 2011 20:01:15 GMT


 Hallo Domnic,

could you show the complete AndroidManifest? And are you sure that your
tag is MIFARE Classic?

br
Michael





-- 



Re: Re: MiFare Classic detection

by Michael Roland » Wed, 13 Apr 2011 20:03:02 GMT


 Hallo,


You should take a look at the foreground activity dispatch:
 http://developer.android.com/reference/android/nfc/Tag.html 

br
Michael

-- 



Re: MiFare Classic detection

by androidom » Wed, 13 Apr 2011 20:04:05 GMT


 Hi Zaid,
You would have to use the RFID reader  and get the data over to your
pc over the serial or usb port.  you can use java for that. either
Global or Open platform. Java Card could be a good starting point..
look for examples using Nokia NFC 6212 classic. This form is about
reading using Android.. or I missed your message..=?
thanks
Domnic





-- 



Re: MiFare Classic detection

by androidom » Wed, 13 Apr 2011 20:49:02 GMT


 Dear Michael,
My Manifest is like this

<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="1" android:versionName="1.0"
    package="com.benya.storm.android.ticketing" xmlns:android="http://
schemas.android.com/apk/res/android">
    <uses-sdk android:minSdkVersion="9" />
    <application android:icon="@drawable/icon" android:label="@string/
app_name" android:debuggable="true">
        <activity android:label="@string/app_name"
android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                              <category
android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
        </activity>

        <activity android:name="verifytagscanact"
                android:permission="android.permission.NFC"
                android:label="@string/event_verify">
                 <intent-filter>
  <action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
           android:resource="@xml/filter_nfc" />
                </activity>
        <activity android:name="verifyconfirmact"
android:permission="android.permission.INTERNET"
android:label="@string/event_verify"></activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.NFC"/>
</manifest>

-- 



Re: Re: MiFare Classic detection

by Michael Roland » Wed, 13 Apr 2011 20:58:34 GMT


 Hallo Domnic,

Strange, the manifest looks good to me.


Your phone is Android 2.3.3 (i.e. API version 10, right?). Otherwise,
the TECH_DETECTED intent is not available.

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I'm not sure why you request the calling app to have the NFC permission.
You might want to try to remove this requirement, eventhough I would
expect the NFC Service to have this permission.

br,
Michael

-- 



Re: MiFare Classic detection

by androidom » Wed, 13 Apr 2011 20:58:50 GMT


 Looks like this would work only on 2.3.3 and above.. and not 2.3.1 ..!

-- 



Re: MiFare Classic detection

by androidom » Wed, 13 Apr 2011 21:02:32 GMT


 Nope the phone is 2.3.1 level 9.. I am afraid as you said it would
work.. I need to flash ver 3 I think.. can we do the upgrade using
windows platform..? any suggestions..perhaps..?

-- 



Re: Re: MiFare Classic detection

by Michael Roland » Wed, 13 Apr 2011 21:09:54 GMT


 Just Google it, you'll find several howtos:
 http://www.google.com/search?hl=en& ;q=update+nexus+s+android+2.3.3

br
Michael





-- 



Other Threads

1. compile error in 2.6.29

I just checked out 2.6.29 and did a make bzImage. I'm seeing following
errors:
ernel/cpuset.c: In function puset_can_attach
kernel/cpuset.c:1360: error: askundeclared (first use in this
function)
kernel/cpuset.c:1360: error: (Each undeclared identifier is reported
only once
kernel/cpuset.c:1360: error: for each function it appears in.)
kernel/cpuset.c: In function puset_print_task_mems_allowed
kernel/cpuset.c:2454: warning: format not a string literal and no
format arguments
make[1]: *** [kernel/cpuset.o] Error 1

and revert patch
2bda29ae9ba43a012a4ea9089dc3362b96f167a8 seems fixed the problem. Is
this a known issue?
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

2. Developer does't see comments on android market from other countries

Good point, sorry. Guess the answer is "oh well.. thats what you get
for not speaking American" ;)

(They insist its being worked on. But given how quickly cyrket went up
and how easy it would be to tie something like that into your dev
console, I'm not sure what their definition of 'working on it' is..)








--~--~---------~--~----~------------~-------~--~----~

3. AlertDialog setDapter

4. layout_gravity does not center the control

5. how make the ListView be above the button

6. Does fastboot tools support large img download?

7. Developer does't see comments on android market from other countries