Forums Register Login

cannot connect to my MySQL db using HttpClient

+Pie Number of slices to send: Send
Hello all,

I'm new to android and I'm trying to write a code that access a MySQL database.

I tried to follow the tutorial from HelloAndroid.com

I have a wamp server on my windows machine, and a MySQL database on it. and here is my code:


but all I get is the error "java.net.SocketException.permission denide".
I tried to change he post's url to "http://www.google.com" I get a java.net.UnknowenHostException
http://www.google.com.

I tried to access my php script using the android web browser, using the address http://10.0.2.2/myscript.php.
I get to the page and it run perfectly. so there is no firewall or server problems. I think.
It is something with my application. any hits, please?

+Pie Number of slices to send: Send
Did you give the app internet permission?
+Pie Number of slices to send: Send
Yes, I put that line in the manifest.xml file.

but maybe not in the right position?


I get the same permission denide error, no matter if I use HttpPost or HttpGet. is that mean anything to you?
+Pie Number of slices to send: Send
It should go in the <manifest> tag.

HttpPost or HttpGet should make no difference. (for the error)
+Pie Number of slices to send: Send
Nope, didn't help.

the manifest file looks like this:



I tried to run this code on eclipse and netbeans. the same error happends.
+Pie Number of slices to send: Send
Can you post the entire code (if it's not to much) and the complete error message?
+Pie Number of slices to send: Send
Ok, here goes.
Thank you so much for your time.

//Class ConnectActivity. the main class



and that's all.

maybe its somthing with the emulator's network settings?
+Pie Number of slices to send: Send
Code looks good, it's working fine over here. When I run it I get the toast message, but that's not strange since it can't connect to that IP on my system. But when I change it to www.google.com it works fine. Can you post the error message including the stacktrace so I can see the line where the error occurs?
+Pie Number of slices to send: Send
I found a solution!

I defined new AVD and used it to run the program. and it works!

This AVD used android 8 with no google APi, while the old one was android 8 with the api.
Is it possible that the API was the problem?
I hope it was someting wromg with the project or AVD configuration. why should the API be a problem?

Thanks, again!
+Pie Number of slices to send: Send
Weird, maybe just restarting the AVD was enough. Google or Android API should make no difference for this piece of code. I've tried it here also on a AVD with google api 8 and it worked just the same.
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 12497 times.
Similar Threads
read php session from android
Post an XML filt to a Web Server
Client Android JSON--- Server side PhP .....error..!!
HttpClient and MultipartEntity vs. Jersey Multipart
connect to "IP" timed out
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:07:11.