sad sad - 6 months ago 98
reST (reStructuredText) Question

Loading Rest data in Android Cordova application using AngularJs

I have an Android project created by Cordova witch consume a REST service provided from spring Rest projet on localhost
using AngularJs, I try to access to the resource using following code:

'use strict';
angular.module('myService', ['ngResource']).
factory('Demande', function ($http, $resource) {

$http.defaults.useXDomain = true;

return $resource('http:// localhost:8080\:8080/springrestprojet/rest/myobject/:id', {}, {
'save': {method:'PUT',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept',
'Access-Control-Request-Headers': 'X-Requested-With, accept, content-type',
'Accept':'application/x-www-form-urlencoded, multipart/form-data',
'Access-Control-Allow-Credentials': 'true'}},

I can open to file


and that shows me the correct

but when I run application in the emulator that gives me just empty views (no data rest).
I changed the ip adress of resource to and to the ip adresse of my machine but that still not working!

I guess there is no communication between my emulator genymotion device and the localhost!

Any proposition please?


Answer Source

Genymotion is running in VirtualBox. You have to change the network configuration. As stated on

The name of the network is vboxnet0, and if you run “ifconfig vboxnet0” (or “ipconfig vboxnet0” if running Windows) on your host machine, you should receive the IP address of your host on the vboxnet0 network. The default IP is most likely This is the IP address to use when accessing your host machine from the Genymotion emulator.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download