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 6659237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:00:35+00:00 2026-05-26T02:00:35+00:00

I have created a simple app where I have an image. Now what I

  • 0

I have created a simple app where I have an image. Now what I want to do is.

  1. At first, I want to add NFC support to my app.

  2. Once I add NFC support in my app, the next thing I want is how can I transfer my image that is present in my app to another device having NFC support.

If anyone knows please help me to solve this out, if possible with an example. I have gone through the documentation as provided in developer.android.com for NFC, but in that case, it only gives transfer of text from one device to another using NFC, but in my case I want to transfer image instead of text.

Code for text transfer

public class NFCTestApp extends Activity 
{   
                                
   private NfcAdapter mAdapter;
   private TextView mText;
   private NdefMessage mMessage;

    public static NdefRecord newTextRecord(byte[] text, Locale locale, boolean enco   deInUtf8) 
    {
       byte[] langBytes = locale.getLanguage().getBytes(Charset.forName("US-ASCII"));

       Charset utfEncoding = encodeInUtf8 ? Charset.forName("UTF-8") : Charset.forName("UTF-16");
       byte[] textBytes = text;

       int utfBit = encodeInUtf8 ? 0 : (1 << 7);
       char status = (char) (utfBit + langBytes.length);

       byte[] data = new byte[1 + langBytes.length + textBytes.length]; 
       data[0] = (byte) status;
       System.arraycopy(langBytes, 0, data, 1, langBytes.length);
       System.arraycopy(textBytes, 0, data, 1 + langBytes.length, textBytes.length);

       return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data);
    }

    public void onCreate(Bundle savedInstanceState) 
    {
       super.onCreate(savedInstanceState);
       mAdapter = NfcAdapter.getDefaultAdapter(this);

       setContentView(R.layout.main);

       
       Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       bm.compress(Bitmap.Compress.JPEG, 100, baos);
       byte[] b = baos.toByteArray();

      // Create an NDEF message 
       mMessage = new NdefMessage(
            new NdefRecord[] { newTextRecord(b, Locale.ENGLISH, true)});  
    }

    @Override
    public void onResume() 
    {
       super.onResume();
       if (mAdapter != null) mAdapter.enableForegroundNdefPush(this, mMessage);
    }

    @Override
    public void onPause() 
    {
       super.onPause();
       if (mAdapter != null) mAdapter.disableForegroundNdefPush(this);
    }
}
  • 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-05-26T02:00:35+00:00Added an answer on May 26, 2026 at 2:00 am

    First, you need to include this in your manifest file to enable NFC support:

    <uses-permission android:name="android.permission.NFC" />
    <uses-sdk android:minSdkVersion="9" />
    <uses-feature android:name="android.hardware.nfc" android:required="true" />
    

    Then you might have a look at NFCDemo, official NFC demo app from Google, for a reference.

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

Sidebar

Related Questions

I have created a simple app. Now I want to have a live wallpaper
I have created a simple JSF image browsing app, and I'm having a problem
I have created a simple web app/form using google app engine. the site is
I have created a small and simple android app. I tried installing it on
So I have a simple web app where I can create a user (UserModel)
Ok so I have a simple Android app that I want it to go
So I created a simple project, which I can test as an iPhone app.
I have managed to create a simple app which deletes (bypassing the recycle bin)
Could someone help me on this, I have created simple web services using axis2
How to manually create Friendly URLs? (PHP) So I have created simple php file

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.