【发布时间】:2015-06-28 08:54:16
【问题描述】:
我想编写一个可以存储唯一 ID 的程序,然后将其作为 NFC 标签共享。我完全想编写可以使用移动设备而不是智能卡的程序。
我在许多网站和这里都读到过它,但我不明白如何将 ID 推送到我的应用程序以及如何通过 NFC 读取器设备共享此 ID
我不知道code below 是做什么的,他们的特点是什么
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
filters = new IntentFilter[] { new IntentFilter(
NfcAdapter.ACTION_TECH_DISCOVERED) };
techLists = new String[][] { { "android.nfc.tech.IsoPcdA" } };
}
public void onResume() {
super.onResume();
if (adapter != null) {
adapter.enableForegroundDispatch(this, pendingIntent, filters,
techLists);
}
}
public void onPause() {
super.onPause();
if (adapter != null) {
adapter.disableForegroundDispatch(this);
}
}
}
【问题讨论】: