locked
How to interrupt bluetooth file transfer in android? RRS feed

  • Question

  • User380079 posted

    Somebody, please guide how to interrupt or cancel at mid of the file transfer in Bluetooth programmatically. My idea is to close the socket. anybody, please guide better idea

    Tuesday, October 22, 2019 12:51 PM

Answers

  • User382871 posted

    My idea is to close the socket. anybody, please guide better idea Closing the socket is just the way to interrupt transfer. Close method will close this stream and releases any system resources associated with it. In particular, BluetoothSocket.Close() will always immediately abort ongoing operations and close the socket. Check the tutorial.

    private BluetoothSocket mmSocket; ... public void Cancel() { try { mmSocket.Close(); } catch (Java.IO.IOException e) { } }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 22, 2019 2:32 PM

All replies

  • User382871 posted

    My idea is to close the socket. anybody, please guide better idea Closing the socket is just the way to interrupt transfer. Close method will close this stream and releases any system resources associated with it. In particular, BluetoothSocket.Close() will always immediately abort ongoing operations and close the socket. Check the tutorial.

    private BluetoothSocket mmSocket; ... public void Cancel() { try { mmSocket.Close(); } catch (Java.IO.IOException e) { } }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 22, 2019 2:32 PM
  • User380079 posted

    Hi @Jarvan , But this code disconnects the Bluetooth device. I just want to cancel the file transfer . I don't want to disconnect Bluetooth device

    Tuesday, November 12, 2019 8:03 AM