Android的PhoneGap的FileTransfer.download()recieving错误code 3 [英] android phonegap FileTransfer.download() recieving error code 3

查看:508
本文介绍了Android的PhoneGap的FileTransfer.download()recieving错误code 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用FileTransfer.download(),但似乎得到错误code 3不管我怎么努力。任何帮助是极大的AP preciated。

I am trying to use FileTransfer.download() but seem to get "error code 3" no matter what I try. Any help is greatly appreciated.

我使用的科尔多瓦2.1和Zend Studio的10,是建立在eclipe打造出我的清单和APK文件。

I am using cordova 2.1 and zend studio 10 which is built on eclipe to build out my manifest and apk files.

下面是我的code

var fileTransfer = new FileTransfer();
    fileTransfer.download(
            "http://www.w3.org/2011/web-apps-ws/papers/Nitobi.pdf",
            "file:///sdcard/theFile.pdf",
        function(entry) {
            alert("download complete: " + entry.fullPath);
        },
        function(error) {
            alert("download error source " + error.source);
            alert("download error target " + error.target);
            alert("upload error code" + error.code);
        });

下面是我的科尔多瓦xml文件

Below is my cordova xml file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.phonegap.example" version="1.0.0" versionCode="1">
  <name>App</name>
  <feature name="http://api.phonegap.com/1.0/file"/>
  <feature name="http://api.phonegap.com/1.0/network"/>
  <feature name="http://api.phonegap.com/1.0/device"/>
  <access origin=".*" />
</widget>

和我的Andr​​oid的manifest.xml

and my android manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.phonegap.example"
    android:versionCode="1"
    android:versionName="1.0.0" 
    >



    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:configChanges="orientation|keyboardHidden"
            android:name=".PhonegapActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我也试着设置机器人:在我的应用程序标签可调试=真正的

I have also tried setting android:debuggable="true" in my application tag

任何帮助是极大AP preciated

Any help is greatly appreciated

推荐答案

所以,我终于发现了问题。
这是一个问题CORS

So I finally found the problem. It was a CORS issues

我有正确的设置在我的科尔多瓦config.xml中

I had the correct setting in my cordova config.xml

<access origin=".*" />

然而,当Zend Studio的内置了我的Andr​​oid项目该设置并没有得到转移到我RES / XML / config.xml中

However, when Zend studio built out my android project this setting did not get transferred over to my res/xml/config.xml

添加接入原线在该文件中的一切后开始按预期工作。

After adding the access origin line in that file everything started working as expected.

这篇关于Android的PhoneGap的FileTransfer.download()recieving错误code 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆