Java 类android.nfc.NfcAdapter.CreateNdefMessageCallback 实例源码

项目:py-eventos-android    文件:NfcSenderUtils.java   
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;
}
项目:ots15-companion    文件:NfcSenderUtils.java   
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;
}
项目:rp15    文件:NfcSenderUtils.java   
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;
}
项目:FMTech    文件:Nfc.java   
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]);
}
项目:libNfc    文件:Nfc.java   
/**
 * Ndef封装消息
 * 
 * @param ndefRecords
 */
public void PushText(String message, CreateNdefMessageCallback callback) {
    PushNdefMessage(new NdefRecord[] {
        buildNdefRecord(message, Locale.ENGLISH, true)
    }, callback);
}
项目:libNfc    文件:Nfc.java   
/**
 * Ndef封装消息
 * 
 * @param message
 */
public void PushUri(Uri uri, CreateNdefMessageCallback callback) {
    PushNdefMessage(new NdefRecord[] {
        NdefRecord.createUri(uri)
    }, callback);
}
项目:libNfc    文件:Nfc.java   
/**
 * Ndef封装消息
 * 
 * @param ndefRecords
 */
public void PushNdefMessage(NdefRecord[] ndefRecords, CreateNdefMessageCallback callback) {
    mNdefMessage = new NdefMessage(ndefRecords);
    mNfcAdapter.setNdefPushMessage(mNdefMessage, mActivity);
    mNfcAdapter.setNdefPushMessageCallback(callback, mActivity);
}