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. how to play video on Android?

Can someone help me figure out how to play video on Android?  I can't
figure out how to refer to the 3gp resource that I added to the
project.  Here's what I've been trying:

/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.***.com/ 
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.apis.media;

import java.net.URI;

import com.example.android.apis.R;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoViewDemo extends Activity {

    /**
     * TODO: Set the path variable to a streaming video URL or a local
media
     * file path.
     */
    private String path = "C:\\Program Files\\{*filter*}Rayne2 Demo\\video\
\logh.mpg";
    private VideoView mVideoView;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.videoview);
        mVideoView = (VideoView) findViewById(R.id.surface_view);

        if (path == "") {
            // Tell the user to provide a media file URL/path.
            Toast.makeText(
                    VideoViewDemo.this,
                    "Please edit VideoViewDemo Activity, and set path"
                            + " variable to your media file URL/path",
                    Toast.LENGTH_LONG).show();

        } else {

            /*
             * Alternatively,for streaming media you can use
             * mVideoView.setVideoURI(Uri.parse(URLstring));
             */

                //Uri path2 = Uri.parse("android.resource://
com.example.android/raw/tempire");

                //Uri path2 = Uri.parse("android.resource://
com.example.android.apis.media/" + R.raw.tempire);

                Uri path2 = Uri.parse("android.resource://apidemos/raw/
tempire");

                mVideoView.setVideoURI(path2);
            //mVideoView.setVideoPath(path);
            mVideoView.setMediaController(new MediaController(this));
            mVideoView.requestFocus();

        }
    }
}

-- 

2. How to add menu items to webview?

I have a webview app and want to add a menu when a user hits the hard
menu button.

I want to have a back, refresh and forward button to help then
navigate pages better.

How can i do this? what code do i need? and how or where will i fit it
in to my .Java file below?

package com.windowcleaningforums;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class windowcleaningforums extends Activity
{
    final Activity activity = this;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.main);

        WebView webView = (WebView) findViewById(R.id.WebView);
        webView.getSettings().setJavaScriptEnabled(true);

        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress)
            {
                activity.setTitle(" Loading...");
                activity.setProgress(progress * 100);

                if(progress == 100)
                    activity.setTitle(R.string.app_name);
            }
        });

        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl)
            {
                // Handle the error
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view,
String url)
            {
                view.loadUrl(url);
                return true;
            }
        });

        webView.loadUrl("http://www.windowcleaningforums.co.uk");
    }
}

-- 

3. Passing data from service to original activity?

4. Working on the formstuff samples and I am getting a error adding the EditText.

5. startActivity(ForResult) at Activity start (on/Create/Start/Resume) not working

6. How to create menu after user clicks a button or any other place in my View object?

7. How to create picasa app??