Can i write an app which sends file (can be an

2019-09-03 14:31发布

问题:

I can send file using below API via NFC Android Beam

mNfcAdapter.setBeamPushUrisCallback()

Do the other device should also have the same app to receive the file?
If Yes then sending this file would not support for other platform like Blackberry even though they are NFC capable device. Please advice.

回答1:

The file transfer implementation does not require the receiving device to have your application. If you send something like a picture, a mime-type will be broadcast when the user clicks the competition notification that 'can' launch an associated application if any are installed.

It is worth noting that you can not force the mime type with android beam file transfers so you can not guarantee that your application will be the only one waiting to receive a specific file type. I would also like to note that in my experience it seems that attempting to send files without an extension will not work. Beam will attempt but never connect for sending in the case of no extension.

If you check the file sending requirements in the dev guide you will see that having the application installed on both devices is not a requirement.

  • Android Beam file transfer for large files is only available in Android 4.1 (API level 16) and higher.
  • Files you want to transfer must reside in external storage. To learn more about using external storage, read Using the External Storage.
  • Each file you want to transfer must be world-readable. You can set this permission by calling the method File.setReadable(true,false).
  • You must provide a file URI for the files you want to transfer. Android Beam file transfer is unable to handle content URIs generated by FileProvider.getUriForFile.

Sending files reference: https://developer.android.com/training/beam-files/send-files.html

Receiving files reference: https://developer.android.com/training/beam-files/receive-files.html