• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Message类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.ndeftools.Message的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Message类属于org.ndeftools包,在下文中一共展示了Message类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ndefWrite

import org.ndeftools.Message; //导入依赖的package包/类
private void ndefWrite() {
	Log.d(TAG, "NDEF write");
	
	Message message = new Message();
	
	UriRecord record = new UriRecord();
	record.setUri(Uri.parse("https://github.com/skjolber/external-nfc-api"));
	
	message.add(record);
	
	try {
		ndef.connect();
		
		ndef.writeNdefMessage(message.getNdefMessage());
		
		ndef.close();
	} catch (Exception e) {
		Log.d(TAG, "Problem writing NDEF message", e);
	}
}
 
开发者ID:skjolber,项目名称:external-nfc-api,代码行数:21,代码来源:MainActivity.java


示例2: ndefFormat

import org.ndeftools.Message; //导入依赖的package包/类
private void ndefFormat() {
	Log.d(TAG, "NDEF format write");
	
	Message message = new Message();
	
	UriRecord record = new UriRecord();
	record.setUri(Uri.parse("https://github.com/skjolber/external-nfc-api"));
	
	message.add(record);
	
	try {
		ndefFormatable.connect();
		
		ndefFormatable.format(message.getNdefMessage());
		
		ndefFormatable.close();
	} catch (Exception e) {
		Log.d(TAG, "Problem writing NDEF message", e);
	}
}
 
开发者ID:skjolber,项目名称:external-nfc-api,代码行数:21,代码来源:MainActivity.java


示例3: showRecords

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * 
 * Show NDEF records in the list
 * 
 */

private void showRecords(Message message) {
	// display the message in the gui
	
	ListView listView = (ListView) findViewById(R.id.recordListView);
	View ndefRecords = findViewById(R.id.ndefRecords);
	if(message != null && !message.isEmpty()) {
		Log.d(TAG, "Show " + message.size() + " records");

		ArrayAdapter<? extends Object> adapter = new NdefRecordAdapter(this, message);
		listView.setAdapter(adapter);
		listView.setVisibility(View.VISIBLE);
		
		ndefRecords.setVisibility(View.VISIBLE);
	} else {
		listView.setVisibility(View.GONE);
		
		ndefRecords.setVisibility(View.GONE);
	}
	
}
 
开发者ID:skjolber,项目名称:external-nfc-api,代码行数:27,代码来源:MainActivity.java


示例4: createNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
@Override
protected NdefMessage createNdefMessage() {
    // Create the NDEF message to be written when a tag is within range.
    Message message = new Message();

    // add an External type Record with the proper message
    String domain = "rnel.rice.edu";
    String externalRecordType = "rsm";

    byte[] byteDomain = domain.getBytes(Charset.forName("UTF-8"));
    byte[] byteType = externalRecordType.getBytes(Charset.forName("UTF-8"));
    byte[] b = new byte[byteDomain.length + 1 + byteType.length];
    System.arraycopy(byteDomain, 0, b, 0, byteDomain.length);
    b[byteDomain.length] = ':';
    System.arraycopy(byteType, 0, b, byteDomain.length + 1, byteType.length);

    byte[] EMPTY = new byte[]{};

    // external type id must be empty
    //NdefRecord record =  new NdefRecord(NdefRecord.TNF_EXTERNAL_TYPE, b, EMPTY, NDEFData);
    GenericExternalTypeRecord record = new GenericExternalTypeRecord(domain, externalRecordType, NDEFData);
    message.add(record);

    return message.getNdefMessage();
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:26,代码来源:NFCWriteActivity.java


示例5: parseNdefRecord

import org.ndeftools.Message; //导入依赖的package包/类
public static SmartPosterRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();

	normalizeMessageBeginEnd(payload);

	SmartPosterRecord smartPosterRecord = new SmartPosterRecord();
	
	if(payload.length > 0) {
		List<Record> records = Message.parseNdefMessage(payload);

		for (Record record : records) {
			if (record instanceof UriRecord) {
				smartPosterRecord.setUri((UriRecord)record);
			}
			else if (record instanceof TextRecord) {
				smartPosterRecord.setTitle((TextRecord)record);
			}
			else if (record instanceof ActionRecord) {
				smartPosterRecord.setAction((ActionRecord)record);
			}
		}
	}
	return smartPosterRecord;
	
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:26,代码来源:SmartPosterRecord.java


示例6: getNdefRecord

import org.ndeftools.Message; //导入依赖的package包/类
@Override
public NdefRecord getNdefRecord() {
	Message message = new Message();
	if (hasTitle()) {
		message.add(title);
	}
	if (hasUri()) {
		message.add(uri);
	}
	if (hasAction()) {
		message.add(action);
	}
	
	return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_SMART_POSTER, id != null ? id : EMPTY, message.getNdefMessage().toByteArray());
	
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:17,代码来源:SmartPosterRecord.java


示例7: createNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * 
 * Implementation of {@link CreateNdefMessageCallback} interface.
 * 
 * This method is called when another device is within reach (communication is to take place).
 */

@Override
public NdefMessage createNdefMessage(NfcEvent event) {
	Log.d(TAG, "Create message to be beamed");
	
	// create message to be pushed, for example
	Message message = new Message();
	// add text record
	message.add(new TextRecord("This is my beam text record"));
	// add 'my' external type record
	message.add(new GenericExternalTypeRecord("my.domain", "atype", "My data".getBytes(Charset.forName("UTF-8"))));
				
	// encode to NdefMessage, will be pushed via beam (now!) (unless there is a collision)
	return message.getNdefMessage();
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:22,代码来源:DefaultNfcBeamWriterActivity.java


示例8: createNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * Create an NDEF message to be written when a tag is within range.
 *
 * @return the message to be written
 */

@Override
protected NdefMessage createNdefMessage() {

    // compose our own message
    Message message = new Message();

    if (uuid != null) {
        // add a Text Record with the message which is entered
        MimeRecord textRecord = new MimeRecord();
        textRecord.setMimeType("application/oly.netpowerctrl");
        textRecord.setData(uuid.toString().getBytes());
        message.add(textRecord);
    }

    // add an Android Application Record so that this app is launches if a tag is scanned :-)
    AndroidApplicationRecord androidApplicationRecord = new AndroidApplicationRecord();
    androidApplicationRecord.setPackageName(getPlayIdentifier());
    message.add(androidApplicationRecord);

    return message.getNdefMessage();
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:28,代码来源:NfcTagWriterActivity.java


示例9: readNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * An NDEF message was read and parsed. This method prints its contents to log and then shows its contents in the GUI.
 *
 * @param message the message
 */

@Override
public void readNdefMessage(Message message) {
    if (message.size() > 1) {
        toast(getString(R.string.readMultipleRecordNDEFMessage));
    } else {
        Record record = message.get(0);
        if (record instanceof ExternalTypeRecord) {
            String domain = ((ExternalTypeRecord) record).getDomain();
            String recordType = ((ExternalTypeRecord) record).getType();
            if ((((ExternalTypeRecord) record).getDomain().equals("rnel.rice.edu")) &&
                    (((ExternalTypeRecord) record).getType().equals("rsm"))) {
                RSMDevice device = new RSMDevice(((ExternalTypeRecord) record).getData());
                if (device.isValid == true) {
                    toast(getString(R.string.readRSMNDEFMessage));
                    rsmDevice = device;
                    updateDeviceDisplay();
                } else {
                    toast(getString(R.string.readRSMMessageError));
                }
            }
            else {
                toast(getString(R.string.readExternalRecordNDEFMessage));
            }
        }
        else {
            toast(getString(R.string.readSingleRecordNDEFMessage));
        }
    }

}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:37,代码来源:MainActivity.java


示例10: nfcIntentDetected

import org.ndeftools.Message; //导入依赖的package包/类
@Override
public void nfcIntentDetected(Intent intent, String action) {
	Log.d(TAG, "nfcIntentDetected: " + action);
	
	Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
	if (messages != null) {
		NdefMessage[] ndefMessages = new NdefMessage[messages.length];
	    for (int i = 0; i < messages.length; i++) {
	        ndefMessages[i] = (NdefMessage) messages[i];
	    }
	    
	    if(ndefMessages.length > 0) {
	    	// read as much as possible
			Message message = new Message();
			for (int i = 0; i < messages.length; i++) {
		    	NdefMessage ndefMessage = (NdefMessage) messages[i];
		        
				for(NdefRecord ndefRecord : ndefMessage.getRecords()) {
					try {
						message.add(Record.parse(ndefRecord));
					} catch (FormatException e) {
						// if the record is unsupported or corrupted, keep as unsupported record
						message.add(UnsupportedRecord.parse(ndefRecord));
					}
				}
		    }
			readNdefMessage(message);
	    } else {
	    	readEmptyNdefMessage();
	    }
	} else  {
		readNonNdefMessage();
	}
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:35,代码来源:NfcReaderActivity.java


示例11: parseNdefRecord

import org.ndeftools.Message; //导入依赖的package包/类
public static HandoverRequestRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();
	
	HandoverRequestRecord handoverRequestRecord = new HandoverRequestRecord();

	byte minorVersion = (byte)(payload[0] & 0x0F);
	byte majorVersion = (byte)((payload[0] >> 4) & 0x0F);

	handoverRequestRecord.setMinorVersion(minorVersion);
	handoverRequestRecord.setMajorVersion(majorVersion);

	normalizeMessageBeginEnd(payload, 1, payload.length -1);

	List<Record> records = Message.parseNdefMessage(payload, 1, payload.length -1);

	if (records.isEmpty()) {
		throw new IllegalArgumentException(
				"Expected collision resolution record and at least one alternative carrier");
	}

	for (int i = 0; i < records.size(); i++) {
		Record record = records.get(i);
		if (record instanceof CollisionResolutionRecord) {
			handoverRequestRecord.setCollisionResolution((CollisionResolutionRecord)record);
		}
		else if (record instanceof AlternativeCarrierRecord)
			handoverRequestRecord.add((AlternativeCarrierRecord)records.get(i));
		// An implementation SHALL silently ignore and SHALL NOT raise an error 
		// if it encounters other unknown record types.
	}

	if (handoverRequestRecord.getAlternativeCarriers().size() == 0)
		throw new IllegalArgumentException("Expected at least one alternative carrier");

	return handoverRequestRecord;
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:37,代码来源:HandoverRequestRecord.java


示例12: parseNdefRecord

import org.ndeftools.Message; //导入依赖的package包/类
public static GenericControlRecord parseNdefRecord(NdefRecord ndefRecord) throws FormatException {
	byte[] payload = ndefRecord.getPayload();

	normalizeMessageBeginEnd(payload, 1, payload.length -1);
	
	Message payloadNdefMessage = Message.parseNdefMessage(payload, 1, payload.length - 1);

	GenericControlRecord genericControlRecord = new GenericControlRecord();
	genericControlRecord.setConfigurationByte(payload[0]);
	
	for (Record record : payloadNdefMessage) {
		if (record instanceof GcTargetRecord) {
			genericControlRecord.setTarget((GcTargetRecord)record);
		} else if (record instanceof GcActionRecord) {
			genericControlRecord.setAction((GcActionRecord)record);
		} else if (record instanceof GcDataRecord) {
			genericControlRecord.setData((GcDataRecord)record);
		} else {
			throw new IllegalArgumentException("Unexpected record " + record.getClass().getName());
		}
	}

	if (!genericControlRecord.hasTarget()) {
		throw new IllegalArgumentException("Expected target record");
	}
	
	return genericControlRecord;
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:29,代码来源:GenericControlRecord.java


示例13: readNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * An NDEF message was read and parsed. This method prints its contents to log and then shows its contents in the GUI.
 * 
 * @param message the message
 */

@Override
public void readNdefMessage(Message message) {
	if(message.size() > 1) {
        toast(getString(R.string.readMultipleRecordNDEFMessage));
	} else {
        toast(getString(R.string.readSingleRecordNDEFMessage));
	}		
	
	this.message = message;
	
	// process message
	
	// show in log
	if(message != null) {
		// iterate through all records in message
		Log.d(TAG, "Found " + message.size() + " NDEF records");

		for(int k = 0; k < message.size(); k++) {
			Record record = message.get(k);
			
			Log.d(TAG, "Record " + k + " type " + record.getClass().getSimpleName());
			
			// your own code here, for example:
			if(record instanceof MimeRecord) {
				// ..
			} else if(record instanceof ExternalTypeRecord) {
				// ..
			} else if(record instanceof TextRecord) {
				// ..
			} else { // more else
				// ..
			}
		}
	}
	
	// show in gui
	showList();
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:45,代码来源:DefaultNfcReaderActivity.java


示例14: createNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * 
 * Create an NDEF message to be written when a tag is within range.
 * 
 * @return the message to be written
 */

@Override
protected NdefMessage createNdefMessage() {
	Message message = new Message();
	
	TextRecord textRecord = new TextRecord();
	textRecord.setText("This is my text");
	textRecord.setEncoding(Charset.forName("UTF-8"));
	textRecord.setLocale(Locale.ENGLISH);
	
	message.add(textRecord);
	
	return message.getNdefMessage();
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:21,代码来源:DefaultNfcTagWriterActivity.java


示例15: readNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * An NDEF message was read and parsed
 * 
 * @param message the message
 */

@Override
protected void readNdefMessage(Message message) {
	if(message.size() > 1) {
        toast(getString(R.string.readMultipleRecordNDEFMessage));
	} else {
        toast(getString(R.string.readSingleRecordNDEFMessage));
	}		
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:15,代码来源:DefaultNfcBeamWriterActivity.java


示例16: TagDescription

import org.ndeftools.Message; //导入依赖的package包/类
public TagDescription(String title, Record record) {
    this.title = title;
    Message message = new Message();
    message.add(record);
    try {
        msgs = new NdefMessage[] {message.getNdefMessage()};
    } catch (final Exception e) {
        throw new RuntimeException("Failed to create tag description", e);
    }
}
 
开发者ID:javawolfpack,项目名称:CSCI567---Workspace,代码行数:11,代码来源:FakeTagsActivity.java


示例17: newIntentEvent

import org.ndeftools.Message; //导入依赖的package包/类
public ArrayList<Record> newIntentEvent(Intent intent) {
    Parcelable[] messages = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
    ArrayList<Record> foundRecords = new ArrayList<Record>();

    if (messages != null) {
        Log.d(this.getClass().getSimpleName(), "Found " + messages.length + " NDEF messages");

        this.vibrate(); // signal found messages

        // parse to records
        for (int i = 0; i < messages.length; i++) {
            try {
                List<Record> records = new Message((NdefMessage)messages[i]);

                Log.d(this.getClass().getSimpleName(), "Found " + records.size() + " records in message " + i);

                for(int k = 0; k < records.size(); k++) {
                    Log.d(this.getClass().getSimpleName(), " Record #" + k + " is of class " + records.get(k).getClass().getSimpleName());

                    Record record = records.get(k);
                    foundRecords.add(record);

                }
            } catch (Exception e) {
                Log.e(this.getClass().getSimpleName(), "Problem parsing message", e);
            }

        }
    }
    return foundRecords;
}
 
开发者ID:figa12,项目名称:sw7,代码行数:32,代码来源:NfcForeground.java


示例18: createNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
/**
 * 書き込むNDEFメッセージを作成するためのメソッドです<br>
 * 書き込み直前に呼ばれます
 */
@Override
protected NdefMessage createNdefMessage() {
  // NDEFレコードの作成
  TextRecord title = new TextRecord("Android");
  UriRecord uri = new UriRecord("http://www.android.com/");
  ActionRecord action = new ActionRecord(Action.DEFAULT_ACTION);
  SmartPosterRecord smartPosterRecord = new SmartPosterRecord(title, uri, action);

  // NDEFメッセージの作成
  Message message = new Message();
  message.add(smartPosterRecord);

  return message.getNdefMessage();
}
 
开发者ID:TechBooster,项目名称:effective_android_sample,代码行数:19,代码来源:MainActivity.java


示例19: readNdefMessage

import org.ndeftools.Message; //导入依赖的package包/类
@Override
protected void readNdefMessage(Message message) {
    for (Record record : message) {
        if (record instanceof MimeRecord) {
            MimeRecord mimeRecord = (MimeRecord) record;
            if (mimeRecord.getMimeType() != null && mimeRecord.getMimeType().equals("application/oly.netpowerctrl")) {
                try {
                    destination_uuid = new String(mimeRecord.getData(), "ASCII");
                } catch (UnsupportedEncodingException ignored) {
                }
            }
        }
    }
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:15,代码来源:ExecutionActivity.java


示例20: write

import org.ndeftools.Message; //导入依赖的package包/类
public boolean write(Message message, Intent intent) {
	return write(message.getNdefMessage(), intent);
}
 
开发者ID:kemerelab,项目名称:RodentDBS,代码行数:4,代码来源:NfcTagWriterActivity.java



注:本文中的org.ndeftools.Message类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TeamRepositoryException类代码示例发布时间:2022-05-22
下一篇:
Java LatLng类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap