2

我正在尝试使用三星移动 SDK 将文件从 Android 主机发送到三星 Gear 设备,无论我如何尝试,总是会出现 FILE_IO 错误。

我正在尝试所有可用的权限(双方)。

谁能给我任何提示?

安卓端:

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);

}
}

我总是会在 tizen 中遇到 FILE_IO 错误的 onError :( 我正在测试 gFileTransfer.receiveFile(transferId, ""); 默认路径和 File:///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"/>

提前感谢您的帮助。

4

1 回答 1

2

更改两个文件路径,它应该可以工作。

将 Android 端更改为:String filename = Environment.getExternalStorageDirectory() + "/Download/TestRecipe2-25.zip";

将 Tizen 的一侧更改为: var newFilePath = "file:///opt/usr/media/Downloads/file.zip";

于 2014-11-06T14:47:59.583 回答