我正在开发一个项目,在该项目中我创建了一个本地 .csv 文件,并且我想使用 NFC 发送这个文件。
到目前为止,这是我活动中的代码。
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
      if (nfcAdapter == null) {          
         return;  // NFC not available on this device
      }
      Uri uri1;
      File root ;
      root= Environment.getExternalStorageDirectory();
      //assign the file path to the uri
      uri1=Uri.fromFile(new File(root, "myFile.csv"));
      nfcAdapter.setBeamPushUris(new Uri[] {uri1}, this);
}
不幸的是,我目前没有其他设备来检查它,但我会在不久的将来这样做。我的问题是当两个设备放在一起时如何将文件发送到另一个设备?通常android有这些功能的监听器。NFC有类似的东西吗?
我正在 Nexus 4 上测试 4.2.2 中的应用程序