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

  • Home
  • SEARCH
  • 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 6243227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:06:03+00:00 2026-05-24T12:06:03+00:00

wondering if anyone might have some insight or point me to the proper documentation

  • 0

wondering if anyone might have some insight or point me to the proper documentation explaining the following line of code:

byte flag = (byte) (flagOfCardData&0x04);

I don’t have any clue as to why there is the &0x04 after flagOfCardData. I know it has to do with something hexadecimal but that is it. Here it the line of code as it sits in the function.

public void onReceiveMsgCardData(byte flagOfCardData,byte[] cardData) {
        // TODO Auto-generated method stub
        byte flag = (byte) (flagOfCardData&0x04);

        if(flag==0x00)
            _strMSRData = new String (cardData);
        if(flag==0x04)
        {
            //You need to dencrypt the data here first.
            _strMSRData = new String (cardData);
        }
        _MSRData = null;
        _MSRData = new byte[cardData.length];
        System.arraycopy(cardData, 0, _MSRData, 0, cardData.length);
        _isCardData = true;
        handler.post(doHideTopDlg);
        handler.post(doHideSwipeTopDlg);
        handler.post(doUpdateTVS);
    }

I would look up why to do this but I can’t even figure out the right search keywords DOH! Thanks for any and all help.

This is for Android sdk using eclipse and java. Also, the code is part of another sdk that is part of a magnetic card reader that connects to an Android powered device through the audio port. The product is called unimag pro. Here is the website: http://www.idtechproducts.com/products/mobile-readers/126.html
I did send them the same question but who knows if and when they might respond. I will post their answer on here as well for anyone else that might come across the same problem.

Let me know if you need any more info.

Thanks.

  • 1 1 Answer
  • 1 View
  • 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-24T12:06:04+00:00Added an answer on May 24, 2026 at 12:06 pm

    Your flagOfCardData is an 8-bit integer, but each bit individually is assigned some independent meaning. In your case, you only want to know its second bit. To do so, you perform bitwise-and with 00000100b, which is 4:

    Mystery byte:  ? ? ? ? ? ? ? ? 
    We want bit 2: 0 0 0 0 0 1 0 0
                   -----------------< bitwise AND
    Result         0 0 0 0 0 X 0 0
    

    Now X is 1 if the second bit is set (1 & 1 = 1), and 0 otherwise (1 & 0 = 0). Thus flagOfCardData & 0x04 is eiter 4 or 0 accordingly.

    It’s customary to just use hexadecimal notation for the individual bits:

    Bit 0: 0x01   Bit 4: 0x10
    Bit 1: 0x02   Bit 5: 0x20
    Bit 2: 0x04   Bit 6: 0x40
    Bit 3: 0x08   Bit 7: 0x80
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling getting some unit tests running and wondering if anyone might have anything
This might have 30 seconds before closing, but I was wondering if anyone knows
I have some unusual I need to do. I am wondering if anyone can
I might be doing a coding competition soon, I was wondering if anyone made
I have a text file, I was wondering anyone have a batch file to
Just wondering if anyone has some good resources for learning how to create new
I have a quad core machine and would like to write some code to
Wondering if anyone out there might know a trick to a small sql script.
Wondering how some of the more experienced (or anyone with a better idea than
We've all been there. You have written some code and unit tests, the tests

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.