0

I made an app that connects to a php file. The code is working using the AVD without a problem. Now when I tried the app in my android device it force closes. My android device is connected through a wifi network. I'm using wamp server on windows 7.

I have pinpointed the problem but I cannot resolve it. I'm hoping one of you good guys can help me. This is my culprit (192.168.1.100 is the machines IP):

private static String url_all_products = "http://192.168.1.100/android_connect/get_all_products.php";

How can this be solved? 100% working in AVD but won't work in actual android device.

droidH
  • 39
  • 1
  • 2
  • 10

4 Answers4

1

@droidH if you working on local server change your url to 10.0.2.2 to your IP address

go to this link it works
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

maddy
  • 205
  • 1
  • 3
  • 6
  • I already tried that. To no avail. I've also been here: [link](http://developer.android.com/tools/devices/emulator.html#networkaddresses) – droidH Mar 15 '13 at 12:09
1

You need to check two things :

  • Your external IP address i.e if you are using windows use command "ipconfig" and get IPv4 address.
  • Check you permissions in AndroidManifest :
uses-permission android:name="android.permission.INTERNET"

Also check : https://stackoverflow.com/a/16510143/644011

Community
  • 1
  • 1
Sanjay Kumar
  • 1,474
  • 14
  • 22
0

Do this:

  • first, put both your android device and your computer into the same network as described here
  • then, make your device connect directly to your computer via its IP in that network (find the IP as here)
Community
  • 1
  • 1
averasko
  • 970
  • 7
  • 15
0
  1. Try to connect your mobile to the same network as your computer. I used virtual router to make my mobile in same network as my laptop
  2. Then use ip address of your computer to access your computer web server from your mobile.