Android NdefMessage - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android NdefMessage class.

This code example shows how to use the following methods: toByteArray
            NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
                    "text/x-su-a".getBytes(),
                    new byte[0], 
                    PreferenceManager.getDefaultSharedPreferences(this)
                            .getString("pin", "").getBytes());
            NdefMessage message = new NdefMessage(new NdefRecord[] {record });
 
            Ndef ndef = Ndef.get(tagFromIntent);
            if (ndef != null) {
                if (!ndef.isWritable()) {
                    Toast.makeText(this, "Tag not writeable", Toast.LENGTH_SHORT).show();
                    return; 
                } 
                 
                int maxSize = ndef.getMaxSize();
                 
                if (maxSize < message.toByteArray().length) {
                    Toast.makeText(this, "Tag not big enough", Toast.LENGTH_SHORT).show();
                    return; 
                } 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    } 
 
    public void testPutSmallToDefaultServer() throws IOException { 
        SnepClient client = new SnepClient();
        client.connect();
        client.put(getSmallNdef());
        client.close();
    } 
 
    public void testPutLargeToDefaultServer() throws IOException { 
        SnepClient client = new SnepClient();
        client.connect();
        client.put(getLargeNdef());
        client.close();
    } 
 
    public void testPutTwiceToDefaultServer() throws IOException { 
        SnepClient client = new SnepClient();
        client.connect();
        client.put(getSmallNdef());

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toByteArray
      this.tag=tag;
    } 
     
    @Override 
    protected Void doInBackground(Void... arg0) {
      int size=msg.toByteArray().length;
 
      try { 
        Ndef ndef=Ndef.get(tag);
         
        if (ndef==null) {
          NdefFormatable formatable=NdefFormatable.get(tag);
           
          if (formatable!=null) {
            try { 
              formatable.connect();
               
              try { 
                formatable.format(msg);
              } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    } 
 
    public void testPutSmall() throws IOException { 
        SnepClient client = getSnepClient();
        client.connect();
        client.put(getSmallNdef());
        client.close();
    } 
 
    public void testPutLarge() throws IOException { 
        SnepClient client = getSnepClient();
        client.connect();
        client.put(getLargeNdef());
        client.close();
    } 
 
    public void testPutTwice() throws IOException { 
        SnepClient client = getSnepClient();
        client.connect();
        client.put(getSmallNdef());

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: toByteArray
 
    /* 
     * Writes an NdefMessage to a NFC tag 
     */ 
    static boolean writeTag(NdefMessage message, Tag tag) {
        int size = message.toByteArray().length;
        try { 
            Ndef ndef = Ndef.get(tag);
            if (ndef != null) {
                ndef.connect();
                if (!ndef.isWritable()) {
                    Log.e(TAG, "Tag is not writable!");
                    return false; 
                } 
                if (ndef.getMaxSize() < size) {
                    Log.e(TAG,
                            "Tag exceeds max ndef message size! [" + size + " > "
                                    + ndef.getMaxSize() + "]");
                    return false; 
                } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android NdefMessage Questions & Answers:

See Code Examples for Android NdefMessage Methods: