aez
aez

Reputation: 2396

How to get image from AppEngine Server into Android activity

I'm trying to fetch an image from the AppEngine server in development mode, using this code from here:

HttpGet httpRequest = new HttpGet(URI.create(url) );
HttpClient httpclient = new DefaultHttpClient();
HttpResponse resp = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = resp.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
bmp = BitmapFactory.decodeStream(instream);

When executing the 3rd line (httpclient.execute(..)) I get the error:

W/System.err(508): org.apache.http.conn.HttpHostConnectException: Connection to http://0.0.0.0:8888 refused

This URL http://0.0.0.0:8888 is correct I believe, because in this App Engine connected Android project, I'm able to fetch images with this address on the browser client side of the project. (Again, I'm in local development mode)

Why is this connection being refused? Thanks.

Upvotes: 1

Views: 622

Answers (1)

Nikolay Elenkov
Nikolay Elenkov

Reputation: 52936

http://0.0.0.0:8888 is certainly not correct. You need to use the IP address of the computer where the App engine development server is running. If you are on a local network that would be something like 192.168.x.xxx. Type ipconfig on Windows or /sbin/ifconfig on Linux in a a terminal to find out the address of your development machine. Then use that to access it from Android.

Upvotes: 4

Related Questions