powered by Jive Software

NullPointerException is asmack file incoming file transfer

I’ve been having serious issues trying to send a file to my android client from a preexisting windows client. The Windows client works fine with incoming/outgoing to other Windows Client. The android client can only send to the Windows client, it can’t recieve.

My code is

FileTransferManager manager = ``new FileTransferManager(connection);

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(``""``, e.getMessage());

``}

``if``(transfer.getStatus().equals(Status.error)) {

``Log.e(``"ERROR!!! "``, transfer.getError() + ``""``);

``}

``if``(transfer.getException() != ``null``) {

``transfer.getException().printStackTrace();

``}

``}

``}``catch (Exception e) {

``Log.e(``""``, e.getMessage());

``}

``};

``}.start();

``}

```});`

The code works fine in that I know the listener fires, I can use transfer.getFileName() and get FileSize to get that information, also, on my client a 0kb file is made when the file is sent from a different client (a windows client using the normal smack library)

In my android log, I get this

E/AndroidRuntime(21814): FATAL EXCEPTION: File Transfer jsi_8313049596512102350

E/AndroidRuntime(21814): java.lang.NullPointerException

E/AndroidRuntime(21814): at org.jivesoftware.smackx.filetransfer.Incoming

FileTransfer.negotiateStream(IncomingFileTransfer.java:179)

E/AndroidRuntime(21814): at org.jivesoftware.smackx.filetransfer.Incoming

FileTransfer$1.run(IncomingFileTransfer.java:124)

E/AndroidRuntime(21814): at java.lang.Thread.run(Thread.java:856)

Which aSmack Version do you use?

1 Like

I’m using 0.8.6