My service is able to send and recive File...... (By this i mean when i send a file from one Android client to another the other client is able to recive the File) the problem is Once a client sends a file It is unable to recive files... (Like let Client A sends a file to Client B .... Client B recives What client A sends.... Now if Client B or Client C Sends any file to Client A, Client A is Not able to Recive File... But Client B can send a file to Client C...) the Log Client a is Showing While Reciving File is
07-16 13:06:34.221: I/System.out(13374): Trying to receive file
07-16 13:06:34.221: I/Recieve File alert dialog(13374): still receiving : 0.0 status Negotiating Stream
07-16 13:06:34.221: I/System.out(13374): Trying to receive file
07-16 13:06:34.221: I/Recieve File alert dialog(13374): still receiving : 0.0 status Negotiating Stream
07-16 13:06:34.221: I/System.out(13374): Trying to receive file
07-16 13:06:34.221: I/Recieve File alert dialog(13374): still receiving : 0.0 status Negotiating Stream
07-16 13:06:34.221: I/System.out(13374): Trying to receive file
07-16 13:06:34.221: I/Recieve File alert dialog(13374): still receiving : 0.0 status Negotiating Stream
07-16 13:06:34.221: I/System.out(13374): Trying to receive file
07-16 13:06:34.221: D/dalvikvm(13374): threadid=21: exiting
07-16 13:06:34.221: D/dalvikvm(13374): threadid=21: bye!
07-16 13:06:34.221: I/Recieve File alert dialog(13374): still receiving : 0.0 status Negotiating Stream
07-16 13:06:34.221: I/System.out(13374): Trying to receive file
07-16 13:06:34.221: I/Recieve File alert dialog(13374): cancelling still receiving : 0.0 status Error
07-16 13:06:34.221: I/System.out(13374): While Receiveing file
07-16 13:06:34.222: I/System.out(13374): Error transfer.getError() : null
07-16 13:06:34.222: I/System.out(13374): transfer.getException() : Error in execution:
07-16 13:06:34.222: I/System.out(13374): -- caused by: java.util.concurrent.ExecutionException:
07-16 13:06:34.222: I/System.out(13374): -- caused by: No response from remote client:
07-16 13:06:34.222: I/System.out(13374): Inside After File Recived
07-16 13:06:34.222: I/System.out(13374): fromName+919932497201@quipit.local/Smack
07-16 13:06:34.222: I/System.out(13374): fromName+919932497201@quipit.local
07-16 13:06:34.222: I/System.out(13374): Inside Add message when called from file recived
07-16 13:06:34.222: I/System.out(13374): Inside findTableName
07-16 13:06:34.222: I/System.out(13374): Inside presentInFrequentUsers
07-16 13:06:34.223: I/System.out(13374): Inside getTableName
07-16 13:06:34.224: I/System.out(13374): before updateLastMessage value of tableNameTABLENAME9932497201
07-16 13:06:34.224: I/System.out(13374): Inside Update last message
07-16 13:06:34.224: I/System.out(13374): messace count:1
07-16 13:06:34.247: I/System.out(13374): mediaTypeimage
07-16 13:06:34.247: I/System.out(13374): addMessageToMessageLog message.is_Text():false
07-16 13:06:34.265: I/System.out(13374): App running Broadcast sent
07-16 13:06:34.265: I/System.out(13374): broadcast recived
And the Error that The Sending Client Gets is:
07-1613:11:52.999: I/transfere file(6066): sending file status NegotiatingStreamprogress:0.0
07-1613:11:52.999: I/System.out(6066):Trying to send file
07-1613:11:52.999: I/transfere file(6066): sending file status NegotiatingStreamprogress:0.0
07-1613:11:52.999: I/System.out(6066):Trying to send file
07-1613:11:52.999: I/transfere file(6066): sending file status NegotiatingStreamprogress:0.0
07-1613:11:52.999: I/System.out(6066):Trying to send file
07-1613:11:53.009: I/transfere file(6066): sending file status NegotiatingStreamprogress:0.0
07-1613:11:53.009: I/System.out(6066):while sending file
07-1613:11:53.009: I/System.out(6066): transfer.getStatus()==Status.error then
07-1613:11:53.009: I/System.out(6066): transfer.getError()::null
07-1613:11:53.009: I/System.out(6066): transfer.getException():Target returned an error: feature-not-implemented(501)
The Recive Function is Like :
publicvoidReceiveFile(){
Thread thread =newThread(){
publicvoid run(){
ServiceDiscoveryManager sdm =ServiceDiscoveryManager
.getInstanceFor(connection);
if(sdm ==null)
sdm =newServiceDiscoveryManager(connection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
// Create the file transfer manager
finalFileTransferManager managerListner =newFileTransferManager(
connection);
FileTransferNegotiator.setServiceEnabled(connection,true);
Log.i("File transfere manager","created");
// Create the listener
managerListner.addFileTransferListener(newFileTransferListener(){
publicvoid fileTransferRequest(finalFileTransferRequest request){
Log.i("Recieve File","new file transfere request new file transfere request new file transfere request");
Log.i("file request","from"+ request.getRequestor());
IncomingFileTransfer transfer = request.accept();
Log.i("Recieve File alert dialog","accepted");
try{
System.out.println("Transfer File Name:"+ transfer.getFileName());
System.out.println("Request File Name:"+request.getFileName());
System.out.println("Resquest desceiption"+ request.getDescription());
finalString fileName = request.getFileName();
transfer.recieveFile(newFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/QuipIt/"+ request.getFileName()));
Log.e("Saving File ","Saving fie recived from Xmpp");
System.out.println("Transfer Path File Name"+ transfer.getFilePath());
while(!transfer.isDone()||(transfer.getProgress()<1)){
// Thread.sleep(1000);
Log.i("Recieve File alert dialog","still receiving : "+(transfer.getProgress())+" status "+ transfer.getStatus());
System.out.println("Trying to receive file");
if(transfer.getStatus().equals(Status.error)){
// Log.i("Error file",
// transfer.getError().getMessage());
Log.i("Recieve File alert dialog","cancelling still receiving : "+(transfer.getProgress())+" status "+ transfer.getStatus());
System.out.println("While Receiveing file");
System.out.println("Error transfer.getError() : "+transfer.getError());
System.out.println("transfer.getException() : "+transfer.getException());
transfer.cancel();
break;
}
}
/*********** work to do when the file receive is complete**************/
System.out.println("Inside After File Recived");
String pathName =Environment.getExternalStorageDirectory().getAbsolutePath()+"/QuipIt/"+ fileName;
System.out.println("fromName"+request.getRequestor());
Stringfrom= request.getRequestor().substring(0,26);
System.out.println("fromName"+from);
String action = request.getDescription();
DBAdapter.addMessage(false,from, pathName,from,false,action);
if(isAppRunning(context)){
// send a broadcast message to the running activity with fromId
System.out.println("App running Broadcast sent");
Intent bIntent =newIntent("ChatActivity");
bIntent.putExtra("fromId",from);
bIntent.putExtra("message", pathName);
bIntent.putExtra("action", action);
LocalBroadcastManager.getInstance(context).sendBroadcast(bIntent);
}else{
// show a notification
String name =DBAdapter.getContactName(request.getRequestor());
if(name ==null){
name ="unknown";
}
sendNotification(context, name,"An Image has come from"+name, request.getRequestor());
}
}catch(XMPPException e){
e.printStackTrace();
}
}
});
}
};
thread.start();
}
The Send File Funtion is like :
publicvoidSendFile(finalStringReceiver,finalStringDirectory,finalString action){
System.out.println("Value in Directory:"+Directory);
Thread thread =newThread(){
publicvoid run(){
ServiceDiscoveryManager sdm =ServiceDiscoveryManager.getInstanceFor(connection);
if(sdm ==null)
sdm =newServiceDiscoveryManager(connection);
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
// Create the file transfer manager
FileTransferManager manager =newFileTransferManager(connection);
FileTransferNegotiator.setServiceEnabled(connection,true);
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(Receiver+"/Smack");
Log.i("transfere file","outgoingfiletransfere is created");
try{
OutgoingFileTransfer.setResponseTimeout(30000);
System.out.println("Path of the File"+Directory);
transfer.sendFile(newFile(Directory),action);
System.out.println("Transfer File Name:"+ transfer.getFileName());
System.out.println("Transfer File Size:"+ transfer.getFileSize());
Log.i("transfere file","sending file");
while(!transfer.isDone()){
try{
// Thread.sleep(1000);
System.out.println("Trying to send file");
Log.i("transfere file","sending file status "+ transfer.getStatus()+"progress: "+ transfer.getProgress());
if(transfer.getStatus()==Status.error){
System.out.println("while sending file \ntransfer.getStatus() == Status.error then \n transfer.getError(): :"+transfer.getError());
System.out.println("\ntransfer.getException():"+transfer.getException());
transfer.cancel();
break;
}
}catch(Exception e){
e.printStackTrace();
}
}
}catch(XMPPException e){
e.printStackTrace();
}
Log.i("transfere file","sending file done");
}
};
thread.start();
The Send funtion is called When the service recives a Broadcast to send a file...
And the Recive Funtion is called When the Connection is estabilish So that it can listen for any incoming File........
Thanks in Advance......... Your help is much appriciated...