Im having a problem with a XMLHttpRequest on Android using Eclipse....
If I build and run the app on a connected device, I get no error but when I build the apk and then install on the device I get an error so Im missing a permission or something. Any help appreciated.
var send = function() {
a = new XMLHttpRequest();
a.open((type.toLowerCase()==="post")?"POST":"GET",self._prepareUrl(url),true);//+'&username='+data.userid,true);
a.onreadystatechange = rsc;
a.timeout = 50000;
setTimeout(function () { /* vs. a.timeout */
if (a.readyState < 4) {
a.abort();
}
}, 50000);
a.ontimeout = to;
a.onerror = err;
a.onabort = errAbort;
a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=iso-8859-1");
a.send(resData);
};
The error function is:
err = function(){
alert('send fail: stat: ' +a.status +' state: ' +a.readyState +' rtext: ' +a.responseText);
},
and the message I get is:
status = 0 state = 4 no response text
so the request has been aborted but why? I must be missing something in the below files as it does work when I run the app via eclipse which must allow something by default but when the apk is built and installed on the device I get the allow permissions info screen on install which does not appear when running via eclipse.
the manifest is:
<?xml version='1.0' encoding='utf-8'?>
<manifest
android:versionCode="5"
android:versionName="1.3"
package="XXXXX"
android:windowSoftInputMode="adjustPan"
xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true"
/>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true">
<activity android:name="CordovaApp" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and the cofig.xml is:
<?xml version='1.0' encoding='utf-8'?>
<widget id="XXXXXXX" version="0.0.1" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
<access origin="*" subdomains="true" />
<log level="DEBUG"/>
<preference name="useBrowserHistory" value="true" />
<preference name="exit-on-suspend" value="true" />
<preference name="disallowOverscroll" value="true" />
<preference name="loadUrlTimeoutValue" value="60000" />
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
</feature>
<feature name="File">
<param name="android-package" value="org.apache.cordova.file.FileUtils" />
</feature>
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device" />
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.network-information" />
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen" />
</feature>
<feature name="Globalization">
<param name="android-package" value="org.apache.cordova.globalization" />
</feature>