Emulator problems

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Emulator problems

Postby GraemeLeech » Mon Feb 21, 2011 11:58 pm

Hi guys,

I am developing an app in Android, and the emulator is not connecting to my localhost. I have researched the issue and found some ideas but nothing seems to be working.

Below is the code i have been using:,

HttpClient httpclient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://10.0.2.2/YES_BUTTON.php"); httpclient.execute(httpPost); I have also tried a connection using "http://10.0.2.2:3128/YES_BUTTON.php", specifying the port 3128 for Apache.

The code would run a php/sql file, but nothing happens, I have also checked the server access log and no connection was ever made with the Apache server from the emulator.

This is my first time building an app, and was wondering if there was something I haven't done, do I need to map the emulator port with the 3128 port on Apache, disable the firewall? I am developing the app on a laptop,with the Apache Server on the laptop also, so everything is being done on the same machine. Is there anything I havent done that needs to be done? I am not using a proxy and don't have a firewall setup. I can also access the Internet through the Emulator, Any ideas?

Much Appreciated, Graeme.
GraemeLeech
Freshman
Freshman
 
Posts: 3
Joined: Mon Feb 21, 2011 11:55 pm

Top

Re: Emulator problems

Postby blundell » Sat Feb 26, 2011 12:53 pm

Got the correct permissions in your android manifest? :-)
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Emulator problems

Postby GraemeLeech » Sat Feb 26, 2011 5:05 pm

yep, I can connect to the internet from the emulator no problem! It just wont connect to Apache on my computer.
GraemeLeech
Freshman
Freshman
 
Posts: 3
Joined: Mon Feb 21, 2011 11:55 pm

Re: Emulator problems

Postby raj_J2ME » Tue Mar 01, 2011 11:04 am

GraemeLeech wrote:yep, I can connect to the internet from the emulator no problem! It just wont connect to Apache on my computer.

What blundell is recommending is to add the permission in the android manifest file, so please check that you have provided the permission for the same. The permission about using internet is "android.permission.INTERNET"

Also this link can of some help,http://www.coderanch.com/t/490312/Android/Mobile/Http-Connection
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 9 guests