我正在使用第三方NFC库与我的NFC标签进行通信。我设法在Tag上使用格式化的NDEF启动我的Activity。
但是,如果我想与Tag进行进一步的通信,我无法做到,因为即使我在getIntent()
方法中调用onResume
,我似乎也失去了意图。我也尝试在onCreate()
中调用它,但它也没有用。
我的代码:
@Override
protected void onResume() {
mLibInstance.startForeGroundDispatch();
Log.d(TAG, "onResume called.");
//final Intent intent = getIntent();
//setIntent(getIntent());
onNewIntent(getIntent());
super.onResume();
}
@Override
protected void onNewIntent(Intent intent) {
Log.d(TAG, "New Intent discovered.");
detectCardType(intent);
super.onNewIntent(intent);
}
它运行所有方法(它来到onNewIntent
)但意图实际上是“丢失”,我无法检测到它是哪种(图书馆告诉我它是未知卡)。但是,如果我在应用程序打开后使用它,它会正确检测到标记。
你们对此有什么建议吗?
谢谢!