Hallo,

>     According to that, I use the API:
> 
> byte[] uid = tagFromIntent.getId();
> byte[] uid = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);

Correct, both of them should return the same value.

> But the results appear in a bunch of strange number, not UID.For
> example:
> 
> DISCOVERED TAG 1,THE DID IS:[B@40529388
> DISCOVERED TAG 2,THE DID IS:[B@40529B10

                              ^^^^^^^^^^^

You should certainly start on learning the basics of the Java
programming language first. The methods return a byte array. What you
did now is to print out the byte array object as string. Java, however,
does not know how the array object should be printed as string, so by
default it prints the objects hash(?) value.

What you need to do is parse the array into a proper string. Typically
you would want to convert each byte in the array into a two digit
hexadecimal string.

br
Michael

> On 8月5日, 下午4时25分, Michael Roland <mi.rol...@gmail.com> wrote:
>> Hallo,
>>
>> the tag object's getId() method should work just fine for most
>> cases[1]. I.e.
>>
>> byte[] uid = tagFromIntent.getId();
>>
>> [1] Note that some tag platforms use random UIDs. For some others the
>> method may return only a partial UID. LikeNFCForum Type 1 tags,
>> where the method returns only 4 bytes of the 7 byte UID (which is
>> correct as only those 4 bytes are used to reference the tag in the
>> transmission protocol.)
>>
>> Besides getId(), this should also work (and give the same result as
>> getId()):
>>
>> byte[] uid = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
>>
>> br
>> Michael
>>
>> On Aug 4, 11:32 am, "xiaodai...@163.com" <zsbitxiao...@163.com> wrote:
>>
>>
>>
>>> Hi,
>>> I just started to research theNFCrelevant content.
>>> I can scan the card, but always don'treadthe card UID.
>>
>>> I want to use getId(),but it cant'nread.
>>> And i see some demo ,using "Tag tagFromIntent =
>>> intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);"
>>> But it outputs a bunch of garbage characters.
>>
>>> How it should bereadthe card UID?
>>
>>> Can anyone help me....Thank you very much!
>>
>>> Regards,
>>> Xiaoxiao- 隐藏被引用文字 -
>>
>> - 显示引用的文字 -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to