Skip to content

Instantly share code, notes, and snippets.

@afjk
Last active December 18, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save afjk/5791922 to your computer and use it in GitHub Desktop.
Save afjk/5791922 to your computer and use it in GitHub Desktop.
StickyNotesActivity::onNewIntent customize for oob
@Override
protected void onNewIntent(Intent intent) {
// NDEF exchange mode
if (!mWriteMode && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
NdefMessage[] msgs = getNdefMessages(intent);
promptForContent(msgs[0]);
}
// Tag writing mode
if (mWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
// del writeTag(getNoteAsNdef(), detectedTag);
// payload直書き
// Creative D100
// 00:02:3C:3A:7E:8A
byte[] textBytes = {
(byte)0x21,(byte)0x00,
(byte)0x8A,(byte)0x7E,(byte)0x3A,(byte)0x3C,(byte)0x02,(byte)0x00,//Bluetooth Device Address:
(byte)0x0E,(byte)0x09,
(byte)0x43,(byte)0x72,(byte)0x65,(byte)0x61,(byte)0x74,(byte)0x69,(byte)0x76,(byte)0x65,(byte)0x20,(byte)0x44,(byte)0x31,(byte)0x30,(byte)0x30,//Bluetooth Local Name
(byte)0x04,(byte)0x0D,(byte)0x04,(byte)0x04,(byte)0x20,//Class of Device:
(byte)0x05,(byte)0x03,(byte)0x1E,(byte)0x11,(byte)0x0B,(byte)0x11};//16-bit Service Class UUID list (complete):
NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, "application/vnd.bluetooth.ep.oob".getBytes(),
new byte[] {}, textBytes);
NdefMessage ndefMessage = new NdefMessage(new NdefRecord[] {
textRecord
});
writeTag(ndefMessage, detectedTag);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment