当前位置: 首页>>代码示例>>Java>>正文


Java CreateNdefMessageCallback类代码示例

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


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

示例1: setAppDataPushMessageCallbackIfAvailable

import android.nfc.NfcAdapter.CreateNdefMessageCallback; //导入依赖的package包/类
public static boolean setAppDataPushMessageCallbackIfAvailable(Activity activity, final CreateNfcAppDataCallback callback) {
	NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
	if (adapter == null) {
		return false;
	}
	final String packageName = activity.getPackageName();
	adapter.setNdefPushMessageCallback(new CreateNdefMessageCallback() {

		@Override
		public NdefMessage createNdefMessage(NfcEvent event) {
			byte[] appData = callback.createNfcAppData();
			if (appData == null) {
				return null;
			}
			NdefRecord[] records = new NdefRecord[] { createMimeRecord("application/" + packageName, appData),
					NdefRecord.createApplicationRecord(packageName) };
			return new NdefMessage(records);
		}

	}, activity);
	return true;
}
 
开发者ID:sysdharma,项目名称:py-eventos-android,代码行数:23,代码来源:NfcSenderUtils.java

示例2: setAppDataPushMessageCallbackIfAvailable

import android.nfc.NfcAdapter.CreateNdefMessageCallback; //导入依赖的package包/类
public static boolean setAppDataPushMessageCallbackIfAvailable(Activity activity, final CreateNfcAppDataCallback callback) {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(activity);
    if (adapter == null) {
        return false;
    }
    final String packageName = activity.getPackageName();
    adapter.setNdefPushMessageCallback(new CreateNdefMessageCallback() {

        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            byte[] appData = callback.createNfcAppData();
            if (appData == null) {
                return null;
            }
            NdefRecord[] records = new NdefRecord[]{createMimeRecord("application/" + packageName, appData),
                    NdefRecord.createApplicationRecord(packageName)};
            return new NdefMessage(records);
        }

    }, activity);
    return true;
}
 
开发者ID:OpnTec,项目名称:ots15-companion,代码行数:23,代码来源:NfcSenderUtils.java

示例3: setCallback

import android.nfc.NfcAdapter.CreateNdefMessageCallback; //导入依赖的package包/类
private void setCallback(NfcAdapter.CreateNdefMessageCallback paramCreateNdefMessageCallback)
{
  if (!this.mFragment.canChangeFragmentManagerState()) {}
  while (this.mNfcAdapter == null) {
    return;
  }
  this.mNfcAdapter.setNdefPushMessageCallback(paramCreateNdefMessageCallback, this.mFragment.getActivity(), new Activity[0]);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:9,代码来源:Nfc.java

示例4: PushText

import android.nfc.NfcAdapter.CreateNdefMessageCallback; //导入依赖的package包/类
/**
 * Ndef封装消息
 * 
 * @param ndefRecords
 */
public void PushText(String message, CreateNdefMessageCallback callback) {
    PushNdefMessage(new NdefRecord[] {
        buildNdefRecord(message, Locale.ENGLISH, true)
    }, callback);
}
 
开发者ID:11-team,项目名称:libNfc,代码行数:11,代码来源:Nfc.java

示例5: PushUri

import android.nfc.NfcAdapter.CreateNdefMessageCallback; //导入依赖的package包/类
/**
 * Ndef封装消息
 * 
 * @param message
 */
public void PushUri(Uri uri, CreateNdefMessageCallback callback) {
    PushNdefMessage(new NdefRecord[] {
        NdefRecord.createUri(uri)
    }, callback);
}
 
开发者ID:11-team,项目名称:libNfc,代码行数:11,代码来源:Nfc.java

示例6: PushNdefMessage

import android.nfc.NfcAdapter.CreateNdefMessageCallback; //导入依赖的package包/类
/**
 * Ndef封装消息
 * 
 * @param ndefRecords
 */
public void PushNdefMessage(NdefRecord[] ndefRecords, CreateNdefMessageCallback callback) {
    mNdefMessage = new NdefMessage(ndefRecords);
    mNfcAdapter.setNdefPushMessage(mNdefMessage, mActivity);
    mNfcAdapter.setNdefPushMessageCallback(callback, mActivity);
}
 
开发者ID:11-team,项目名称:libNfc,代码行数:11,代码来源:Nfc.java


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