2

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

Luciano Rodríguez
  • 2,239
  • 3
  • 19
  • 32
droida
  • 141
  • 1
  • 9
  • `ArrayList availableFiles ...`. Well there you have all ... available files (or better: file descripters of available files). In the next statement you picked the first from the list. And in the last statement you requested a download. What is exactly the problem to download more? – greenapps Nov 22 '14 at 07:56
  • well,the problem is how to transfer several selected files with one time interaction,such as i press the button [send],then the chosen files selected by the check-Box can be send from device A to device B (Android OS).@greenapps,thx – droida Nov 22 '14 at 08:09
  • I will not answer your new questions. You have several problems. I selected one of your problems. Please reread my comment and react to the point. – greenapps Nov 22 '14 at 08:43
  • um,fine,it is the demand above,i.e."how to transfer several selected files with one time interaction,such as i press the button [send],then the chosen files selected by the check-Box can be send from device A to device B (Android OS)"@greenapps,many thx – droida Nov 22 '14 at 09:12
  • Are you intentially not reacting on my comment? In this way i cannot help you. – greenapps Nov 22 '14 at 09:14
  • come on,man,do not take me wrong,i reread what you said for times,um....sorry ,i can't get it through just,would you please just tell me how ,my coding is poor,ur reply is always appreciated.thx @greenapps – droida Nov 22 '14 at 10:59
  • If you do not understand parts my comment or my understanding/explanation is wrong please say so. If you understand it than (i repeat) tell exactly your problem to download more. – greenapps Nov 22 '14 at 12:36

1 Answers1

2

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.

droida
  • 141
  • 1
  • 9