NFC Mock Tags and Successfully Writing NFC Tags

by muasif80 » Mon, 31 Jan 2011 18:07:13 GMT


Sponsored Links
 I would like to ask one thing about NFC demo available in gingerbread.
There are three mocked nfc tags available in this demo. Now can anyone
tell me how can I create one more mocked tag.

For example we have

/**
     * A Smart Poster containing a URL and no text.
     */
    public static final byte[] SMART_POSTER_URL_NO_TEXT =
        new byte[] {(byte) 0xd1, (byte) 0x02, (byte) 0x0f, (byte)
0x53, (byte) 0x70, (byte) 0xd1,
            (byte) 0x01, (byte) 0x0b, (byte) 0x55, (byte) 0x01, (byte)
0x67, (byte) 0x6f,
            (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte)
0x2e, (byte) 0x63,
            (byte) 0x6f, (byte) 0x6d};

Inside MockNdefMessages.java

Now this data is actually the  http://www.google.com/ 
Now I want to have  http://www.wikipedia.com/ in my 
SMART_POSTER_URL_NO_TEXT data member. How can I get the bytes for it
any idea.

Also I have seen that the people at Gibraltar Software Factory have
successfully used the NFC feature of gingerbread to write NFC tags.
Here is the url  http://gibraltarsf.com/blog/?p=13 but they did not 
provide complete code, if someone can see there demo and build
complete code for that demo and share then it will be pleasure for me.

Regards,
Asif

-- 



Re: NFC Mock Tags and Successfully Writing NFC Tags

by Jie Sheng Chua » Fri, 20 May 2011 09:34:02 GMT


 Hi Asif,

SMART_POSTER_URL_NO_TEXT is equivalent to a NdefRecord.TNF_WELL_KNOWN and
NdefRecord.RTD_URI record.
i create a generic method to create these record.
after you retrieve the NdefRecord, you could get the bytes via
NdefRecord.toByteArray().
the code is here,
 http://freakcodes.blogspot.com/2011/05/ndefrecordgeneratorjava.html 

i have other related code here,
 http://freakcodes.blogspot.com/search/label/nfc 
the full project code is also available here,
 http://www.comp.nus.edu.sg/ ~jiesheng/dl/android/whollyNFC.zip

Jie Sheng

-- 
Jie Sheng, Chua
(+65) 97520245
chuajiesh...@gmail.com

The contents of this email are confidential to the intended recipient and
may not be disclosed. Although it is believed that this email and any
attachments are virus free, it is the responsibility of the recipient to
confirm this.




-- 


Sponsored Links


Other Threads

1. Compatibility issue?

Hello.

The following code works just fine on Android 1.5/1.6. However on
2.0.1 I get an exception (see below).

                ContentResolver contentResolver = getContentResolver();
                Uri uri = Uri.withAppendedPath(Contacts.People.CONTENT_URI, Long
                                .toString(item.getId()));
                // lesen des Notizfeldes
                Cursor c = contentResolver.query(uri, null, null, null, null);
                if (c != null) {
                        if (c.moveToFirst()) {
                                String notes = 
c.getString(c.getColumnIndex(People.NOTES));
                                // Aktualisieren des Eintrags
                                ContentValues values = new ContentValues();
                                values.put(People.NOTES, 
TKDateUtils.getStringFromDate(item
                                                .getBirthday(), notes));
                                contentResolver.update(uri, values, null, null);
                        }
                        c.close();

The exception is as follows. Could somebody please explain what is
going on? Thank you very much in advance.

Regards
Thomas

01-03 15:06:00.624: ERROR/DatabaseUtils(98): Writing exception to
parcel
01-03 15:06:00.624: ERROR/DatabaseUtils(98):
java.lang.IllegalArgumentException: Empty values
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
android.database.sqlite.SQLiteDatabase.updateWithOnConflict
(SQLiteDatabase.java:1521)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:
1499)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.ContactsProvider2.updateRawContact
(ContactsProvider2.java:3048)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.ContactsProvider2.updateRawContacts
(ContactsProvider2.java:3020)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.ContactsProvider2.updateInTransaction
(ContactsProvider2.java:2899)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.SQLiteContentProvider.update
(SQLiteContentProvider.java:139)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.ContactsProvider2.update
(ContactsProvider2.java:1947)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.LegacyApiSupport.updatePeople
(LegacyApiSupport.java:1046)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.LegacyApiSupport.update
(LegacyApiSupport.java:1000)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.LegacyApiSupport.updateAll
(LegacyApiSupport.java:986)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.LegacyApiSupport.update
(LegacyApiSupport.java:964)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.ContactsProvider2.updateInTransaction
(ContactsProvider2.java:2948)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.SQLiteContentProvider.update
(SQLiteContentProvider.java:139)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
com.android.providers.contacts.ContactsProvider2.update
(ContactsProvider2.java:1947)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
android.content.ContentProvider$Transport.update(ContentProvider.java:
180)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
android.content.ContentProviderNative.onTransact
(ContentProviderNative.java:195)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
android.os.Binder.execTransact(Binder.java:287)
01-03 15:06:00.624: ERROR/DatabaseUtils(98):     at
dalvik.system.NativeStart.run(Native Method)

-- 

2. Bug:android emulator does not complain with wrong or non existant avd

Hi,

When the android emulator is tarted with non existing avd value, it
does not start the emulator nor gives any error message. It may be
good to let the user know that avd xyz supplied did not exist.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com

-- 

3. Eclipse error when trying to install the ADT Plugin

4. "Sorry, this video is not available." when tapping on an embedded YouTube video from the Android browser

5. Android for stock trading

6. New Year Wishes to the Android team/community.

7. SOLD WTS: HTC Magic white seken