本文整理汇总了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;
}
示例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;
}
示例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]);
}
示例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);
}
示例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);
}
示例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);
}