【发布时间】:2020-01-20 07:47:27
【问题描述】:
我正在尝试在 android 中进行 NFC 标记。 我的活动在 onCreate() 中有一个 webview 及其设置的 url。 NFC标签时,可以正常获取NDEF信息,但不维护页面地址。
我该如何解决?
@Override
public void onCreate(Bundle savedInstanceBundle){
super.onCreate(savedInstanceBundle);
setContentView(R.layout.activity_test);
this.webview = findViewbyId(R.id.webview);
this.webview.loadUrl("https://www.abcblarblar.com/");
this.nfcAdapter = NfcAdapter.getDefaultAdapter(this);
}
@Override
public void onResume(){
super.onResume();
Intent intent = getIntent();
if (NfcAdapter.ACTION_TAG_DISCOVERED == intent.getAction()) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
...
}
}
manifest.xml
<activity
android:name="com.xxx.xxx.xxx.NFCActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
【问题讨论】:
标签: android webview tags nfc ndef