I'm looking at the new Background functionality in 2.3 but the 2 things I want to do keep failing and I don't get why.
The first thing I want to do is fetch some JSON and pass the data back to the app.
function onTemporalEvent() {
System.println("temporal event");
var url = "http://ip.jsontest.com/";
Communications.makeWebRequest(
url,
{},
{},
method(:responseCallback)
);
}
function responseCallback(responseCode, data) {
System.println("got data");
System.println(responseCode);
System.println(data);
if(responseCode == 200) {
Background.exit(data);
} else {
System.println("FETCH FAILED");
Background.exit(null);
}
}
This gets me
temporal event
got data
-1001
null
FETCH FAILED
Second thing I wanted to do was getting position from background.
function onTemporalEvent() {
System.println("temporal event");
Position.enableLocationEvents(Position.LOCATION_ONE_SHOT, method(:onPosition));
}
function onPosition(info) {
System.println("position");
System.println(info.position.toDegrees());
}
and this is what I get
temporal event
Permission requiredFailed invoking <symbol>
And yes, I do have all the permissions
<iq:permissions>
<iq:uses-permission id="Positioning"/>
<iq:uses-permission id="Background"/>
<iq:uses-permission id="Communications"/>
</iq:permissions>
Am I doing something retarded or did I find a bug?
Thanks,
Miha