Android 我希望如何使用nfc阅读器在片段中的同一页面中获取值?

Android 我希望如何使用nfc阅读器在片段中的同一页面中获取值?,android,android-layout,listview,Android,Android Layout,Listview,当我标记NFC卡时。我直接进入主页。但我想在同一页中使用片段。 @覆盖 public void onResume(){ super.onResume(); Intent-Intent=getActivity().getIntent(); String action=intent.getAction(); if(NfcAdapter.ACTION_TAG_DISCOVERED.equals(ACTION)){ Tag Tag=intent.getParcelableExtra(NfcAdapter

当我标记NFC卡时。我直接进入主页。但我想在同一页中使用片段。
@覆盖
public void onResume(){
super.onResume();
Intent-Intent=getActivity().getIntent();
String action=intent.getAction();
if(NfcAdapter.ACTION_TAG_DISCOVERED.equals(ACTION)){
Tag Tag=intent.getParcelableExtra(NfcAdapter.EXTRA_Tag);
if(tag==null){
nNfcNumber.setText(“tag==null”);
}其他{
String tagInfo=“”;
byte[]tagId=tag.getId();
for(inti=0;i
tagInfo+=Integer.toHexString(tagId[i]&0xFF)+;
}
tagInfo+=”;
nNfcNumber.setText(tagInfo);
nNFcnumber=nNFcnumber.getText().toString().trim();
Log.d(“dfdgdf”,即“+nNFcnumber”);
}
}其他{
}

}

是否要从片段中访问活动的变量?发布您到目前为止所做的工作是否要从片段中访问活动的变量?发布您到目前为止所做的工作