how to transfer several files selected one time using alljoyn

469 views Asked by At

I am trying to transfer files using Alljoyn framework, and the sample given by the Alljoyn shows me how to send and receive one file selected by one click on the ListView of the fileExplorer. the problem is i wanna transfer several selected files,e.g. 4 pics,one time.

in the onActivityResult() when case OFFER_SELECTED_FILE:i modefied as follows:

case OFFER_SELECTED_FILE: {

    final String[] peers = ajManager.getPeers();
    //create the click listener - when a peer is selected, offer them the file
    DialogInterface.OnClickListener onPeerClicked = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            String peer = peers[which];
            //File file = (File) intent.getExtras().get("file"); 
            File selected = (File) intent.getExtras().get("file"); 

            ArrayList<String> filePath = new ArrayList<String>();
            filePath.add(selected.getAbsolutePath());
            //ftComponent.offerFileToPeer(peer, file.getAbsolutePath(), 1000);                      
            ftComponent.offerFileToPeer(peer, filePath, 1000);                      
        }
    };
    showPeerPickerDialog(onPeerClicked);
    break;
}

but it's denied by the public class FileTransferComponent which cannot be modified.

public int offerFileToPeer(String peer, String filePath, int timeoutMSecs) {

    return offerManager.offerFile(peer, filePath, timeoutMSecs);
}

and i refered the *File Transfer Module Usage Guide for Android*4.1.1 Basic File Transfer procedures as follows:

Sender Side

ftComponent.announce(filePaths);

Receiver Side

ArrayList<FileDescriptor> availableFiles = ftComponent.getAvailableRemoteFiles();
FileDescriptor selected = availableFiles.get(0);
ftComponent.requestFile(selected.owner, selected.fileId, selected.filename);

help ,any suggestion will be appreciated.i am new about the alljoyn. if possible,please tell me how to do both the Receicer&&Sender sides.thx

1

There are 1 answers

0
droida On BEST ANSWER

well,i got the solution days ago, as follows:

 //ready the selected the files's path list
  File selected = (File) intent.getExtras().get("file");
  filePaths = new ArrayList<String>();
  filePaths.add(selected.getAbsolutePath());    
 //in the offer event
 private FileTransferComponent ftComponent;
  for (String path : filePaths) {
      ftComponent.offerFileToPeer(peer, path, 1000);//the sample's original statement
      }

the Alljoyn sample shows me transfer one file,thus we just need to use something like for(a:a_list){...} to do with it.and the Alljoyn will handle the rest.

ps.i have got a headache with people who just talk big but no suggested output.if u are too proud to answer some question,please do not waste time here.Thx.