I use Smack and xmpp to send messages in the application, the question arose how to get the file in the application correctly.
I use this file transfer listener to get the files in the application:
manager.addFileTransferListener (new FileTransferListener() { public void fileTransferRequest(final FileTransferRequest request) { new Thread() { @Override public void run() { IncomingFileTransfer transfer = request.accept(); File mf = Environment.getExternalStorageDirectory(); File file = new File(mf.getAbsoluteFile() + "/DCIM/Camera/" + transfer.getFileName()); try { transfer.recieveFile(file); while (!transfer.isDone()) { try { Thread.sleep(1000L); } catch (Exception e) { Log.e("Error", e.getMessage()); } if (transfer.getStatus().equals(FileTransfer.Status.error)) { Log.e("ERROR!!! ", transfer.getError() + ""); } if (transfer.getException() != null) { transfer.getException().printStackTrace(); } } Log.e("", e.getMessage()); } } }.start(); } });
I use the OpenFire server, and I also downloaded the Psi client for sending messages and testing. When I try to send a Psi file to a user who has an Android application installed on the phone, Psi requests the request before sending the file, и когда я проверяю в дебаггере, то программа не заходит в строчку кода IncomingFileTransfer transfer = request.accept (); How to accept this request on the phone programmatically? What's wrong?
