简体   繁体   中英

Android app running on emulator Sync to app on localhost?

I am implementing C2DM (possibly not relevant) in an android app testing on an emulator. I have just got the C2DM registration working with the C2DM service so now I need to register my app with my web app,

As my web app is in dev mode (Rails METAL server) it is running on http://localhost:3020

I need to know if this is reachable from the emulator as I'm not getting anything through to the web app when the registration ID is received in response to the Google C2DM registration process by the andropid app and I'm struggling to work out if I have an issue with my code or if this is because localhost is not reachable.

Thanks in advance for any information on this

UPDATE I found out from http://developer.android.com/guide/developing/devices/emulator.html#networkaddresses that 10.0.2.2 will route to 127.0.0.1 but not sure how that would help me get to http://localhost:3020

I'm using a global variable for this

public static final String SERVER_BASE_URL = "http://localhost:3000";

Any ideas what I should set this to?

Try SERVER_BASE_URL = "http://10.0.2.2:3020"; as 10.0.2.2 is going to be "your host loopback interface (ie, 127.0.0.1 on your development machine )" as per the link you posted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM