Android Open Source - wherewithal Mock Ndef Messages






From Project

Back to project page wherewithal.

License

The source code is released under:

GNU General Public License

If you think the Android project wherewithal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.curchod.domartin;
// ww  w . j a  v a 2  s .c o m
import java.math.BigInteger;

/**
 * This class provides a list of fake NFC Ndef format Tags.
 * It comes from the API Level 15 Android NFCDemo source code.
 */
public class MockNdefMessages 
{
  
  public static byte[] getPromulgation()
  {
    String plain_text = "en2467473067840752146@promulgation";
      String hex = toHex(plain_text);
      byte[] bytes = hexStringToByteArray(hex); 
      return bytes;
  }
  
  /**
   * by Dave L. with 14.6k (that's 14600 reputation points.  Go Dave!
   * @param s
   * @return
   */
  public static byte[] hexStringToByteArray(String s) 
  {
      int len = s.length();
      byte[] data = new byte[len / 2];
      for (int i = 0; i < len; i += 2) 
      {
          data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                               + Character.digit(s.charAt(i+1), 16));
      }
      return data;
  }
  
  /**
   * by Kaleb Pederson 15700 reputation points
   * @param arg
   * @return
   */
  public static String toHex(String arg) 
  {
      return String.format("%040x", new BigInteger(arg.getBytes(/*YOUR_CHARSET?*/)));
  }

    /**
     * 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};

    /**
     * A plain text tag in english.
     */
    public static final byte[] ENGLISH_PLAIN_TEXT =
        new byte[] {(byte) 0xd1, (byte) 0x01, (byte) 0x1c, (byte) 0x54, (byte) 0x02, (byte) 0x65,
            (byte) 0x6e, (byte) 0x53, (byte) 0x6f, (byte) 0x6d, (byte) 0x65, (byte) 0x20,
            (byte) 0x72, (byte) 0x61, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x6d,
            (byte) 0x20, (byte) 0x65, (byte) 0x6e, (byte) 0x67, (byte) 0x6c, (byte) 0x69,
            (byte) 0x73, (byte) 0x68, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x78,
            (byte) 0x74, (byte) 0x2e};

    /**
     * Smart Poster containing a URL and Text.
     */
    public static final byte[] SMART_POSTER_URL_AND_TEXT =
        new byte[] {(byte) 0xd1, (byte) 0x02, (byte) 0x1c, (byte) 0x53, (byte) 0x70, (byte) 0x91,
            (byte) 0x01, (byte) 0x09, (byte) 0x54, (byte) 0x02, (byte) 0x65, (byte) 0x6e,
            (byte) 0x47, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65,
            (byte) 0x51, (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};

    /**
     * All the mock Ndef tags.
     */
    public static final byte[][] ALL_MOCK_MESSAGES =
        new byte[][] {SMART_POSTER_URL_NO_TEXT, ENGLISH_PLAIN_TEXT, SMART_POSTER_URL_AND_TEXT};
}




Java Source Code List

com.curchod.domartin.AsyncLoadGameFile.java
com.curchod.domartin.Constants.java
com.curchod.domartin.Filer.java
com.curchod.domartin.HouseDeck.java
com.curchod.domartin.IWantTo.java
com.curchod.domartin.MockNdefMessages.java
com.curchod.domartin.NfcUtils.java
com.curchod.domartin.RemoteCall.java
com.curchod.domartin.Sarray.java
com.curchod.domartin.Scoring.java
com.curchod.domartin.TagDescription.java
com.curchod.domartin.UtilityTo.java
com.curchod.dto.Card.java
com.curchod.dto.DeckCard.java
com.curchod.dto.GameWord.java
com.curchod.dto.Game.java
com.curchod.dto.PlayerInfo.java
com.curchod.dto.SavedTest.java
com.curchod.dto.SingleWordTestResult.java
com.curchod.dto.SingleWord.java
com.curchod.json.VocabularyDefinition.java
com.curchod.json.VocabularyLearningObject.java
com.curchod.wherewithal.AddPlayerActivity.java
com.curchod.wherewithal.CardDeckActivity.java
com.curchod.wherewithal.CardDecksActivity.java
com.curchod.wherewithal.CardPlayerHouseDeckActivity.java
com.curchod.wherewithal.CardPlayerWordsActivity.java
com.curchod.wherewithal.CardPlayersListActivity.java
com.curchod.wherewithal.CardsActivity.java
com.curchod.wherewithal.GameConcentrationActivity.java
com.curchod.wherewithal.GameReadingStonesActivity.java
com.curchod.wherewithal.GameReadingStonesInstructionsActivity.java
com.curchod.wherewithal.GameSnazzyThumbworkActivity.java
com.curchod.wherewithal.GameWritingStonesActivity.java
com.curchod.wherewithal.GamesActivity.java
com.curchod.wherewithal.InstructionsActivity.java
com.curchod.wherewithal.MainActivity.java
com.curchod.wherewithal.PlayerActivity.java
com.curchod.wherewithal.PlayersActivity.java