Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8059275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:37:14+00:00 2026-06-05T09:37:14+00:00

I have tried a lot of methods, nothing worked for me. The code below

  • 0

I have tried a lot of methods, nothing worked for me. The code below shows the ndefmessage but it is not in a readable format. It displays some ndef message format as b@15d…

public void onNewIntent(Intent intent) {
  Tag myTag = (Tag)intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
  def ndefTag = Ndef.get(myTag);
  int size = ndefTag.getMaxSize();         // tag size
  String type = ndefTag.getType();         // tag type
  NdefMessage ndefMesg = ndefTag.getCachedNdefMessage();
  NdefRecord[] ndefRecords = ndefMesg.getRecords();
  int len = ndefRecords.length;
  for (int i = 0; i < len; i++) {
    typ = ndefRecords[i].getType();
    payload = ndefRecords[i].getPayload();
  }
  String textEncoding = ((payload[0] & 0200) == 0) ? "UTF-8" : "UTF-16";
  int languageCodeLength = payload[0] & 0077;
  try {
    @SuppressWarnings("unused")
    String languageCode = new String(payload, 1,languageCodeLength,"US-ASCII");
  } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  try {
    text =new String(payload,languageCodeLength+1,payload.length
      -languageCodeLength - 1, textEncoding);
    Toast.makeText(getApplicationContext(),
      text+"First Try",Toast.LENGTH_LONG).show();
    mText.setText("Discovered tag "+text);
  } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    String val = new String(typ);
    val+=new String(payload);
    Toast.makeText(getApplicationContext(),
      "Second"+val,Toast.LENGTH_LONG).show();
  }
  Log.i("Foreground dispatch", "Discovered tag with intent: " + intent);
  mText.setText("Discovered tag "+text);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:37:16+00:00Added an answer on June 5, 2026 at 9:37 am

    The payload of an NdefRecord is not necessarily a String.

    You need to look at the Type Name Format (TNF) and the Type to determine how to decode the payload.

    If you’ve encoded a String in the payload when you wrote the tag new String(record.getPayload()) will work fine.

    If you’ve written a plain text tag with some other software, it is probably tnf TNF_WELL_KNOWN type RTD_TEXT. In that case the payload byte array will contain the language code as the first byte of the String. See http://developer.android.com/resources/samples/NFCDemo/src/com/example/android/nfc/record/TextRecord.html for an example on how to parse the payload.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a lot and tried much but I can not find the
I have tried <%= render :template =>'resources/new', :format => js %> , but nothing
I tried a lot of methods to do that, but I still have a
OK i have tried a lot of different methods for this. I want to
I have tried a lot to get this done but I dont know how
I have tried all the normal methods of faking keyboard actions (SendInput/SendKeys/etc) but none
I have tried multiple date formats, but still I get nil back: Thu May
I have tried posting this earlier and had to delete it because the code
I know a lot of people have posted for this, but I'm still having
I have a lot of legacy code that is now a backend for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.