2

我試圖從Android主機發送文件到使用三星移動SDK的三星齒輪設備,無論我怎麼嘗試,總是得到FILE_IO錯誤。Gear SDK SAFileTransfer FILE_IO錯誤

我正在嘗試所有可用的權限(雙方)。

任何人都可以給我任何提示嗎?

Android的一面:

String filename = "file:///storage/emulated/0/Download/TestRecipe2-25.zip"; 
if (mGuruAgentService != null) mGuruAgentService.sendFile(filename); 

public int sendFile(String fileName) { 
    if (mFileTransfer == null) 
    registerForFileTransfer(); 
    if (mFileTransfer != null) { 


    try { 
    Log.i(TAG, "Sending file " + fileName); 
    tx = mFileTransfer.send(mPeerAgent, fileName); 
    return tx; 
    } catch (Exception e) 
    { 
    Log.i(TAG, "Cannot send file" + e.getMessage()); 
    } 

} 
return 0; 
} 

Tizen方:

function fileReceiveInt() { 
var newFilePath = "downloads/file.zip"; 

var receivefilecallback = 
{ 
onreceive: function(transferId, fileName) 
{ 
console.log("Incoming file transfer request form the remote peer agent. transferId: " + transferId + " file name : " + fileName); 

try { 
gFileTransfer.receiveFile(transferId, newFilePath); 
} catch(e) { 
console.log("Error Exception, error name : " + e.name + ", error message : " + e.message); 
} 
}, 
onprogress: function(transferId, progress) 
{ 
console.log("onprogress transferId: " + transferId + ", progress : " + progress); 
}, 
oncomplete: function(transferId, localPath) 
{ 
console.log("File transfer complete. transferId: " + transferId); 
}, 
onerror: function(errorCode, transferId) 
{ 
console.log("FileReceiveError transferId: " + transferId + " code : " + errorCode); 
} 
} 


try { 
console.log('setting recieve interface'); 
gFileTransfer = SAAgent.getSAFileTransfer(); 
gFileTransfer.setFileReceiveListener(receivefilecallback); 

} catch (err) { 
console.log('getSAFileTransfer exception <' + err.name + '> : ' + err.message); 

} 
} 

我總是會得到的onError在tizen與FILE_IO錯誤:( 我測試gFileTransfer.receiveFile(transferId, 「」);默認路徑,文件:/// opt/usr/media/Downloads ...

我的tizen權限:

<tizen:privilege name="http://tizen.org/privilege/content.read"/> 
<tizen:privilege name="http://developer.samsung.com/privilege/accessoryprotocol"/> 
<tizen:privilege name="http://tizen.org/privilege/content.write"/> 
<tizen:privilege name="http://tizen.org/privilege/filesystem.read"/> 
<tizen:privilege name="http://tizen.org/privilege/filesystem.write"/> 
<tizen:privilege name="http://tizen.org/privilege/unlimitedstorage"/> 

在此先感謝您的幫助。

回答

2

更改兩個文件路徑,它應該工作。

將Android的端改爲: String filename = Environment.getExternalStorageDirectory()+「/Download/TestRecipe2-25.zip」;

將Tizen的一面更改爲: var newFilePath =「file:///opt/usr/media/Downloads/file.zip」;