I need to send an image file from the mobile to the server(where the server will save it to the hard disk). I have wrote both the android mobile part and the server side. I need to test the code before deploying to the server. Will the code work if I connect the mobile to the WI-Fi network through which I can have a LAN connection to the system? Is there any way I can test the code with out using a WI-Fi connection(ie Connecting phone to the system via the usb cable and then forming a LAN or something)? Please voice your valuable opinion in these stuff.
When I was testing my server-side I didn't find any other way rather than connecting via wifi, this way it was working just fine (in your code you need to use ipv4, not localhost, just as reminder). I'm not good with network stuff, but I don't think it's possible using usb to create some kind of LAN.
Have u tried from emulator? How to connect to my http://localhost web server from Android Emulator in Eclipse
Related
I'm making client program for android watch (of android wear OS) using socket connection.
In my server & client program for general computer, I'm trying to change the client part to that for android watch. But, I cannot find a sample code related to socket connection for android watch (of android wear OS).
I learned that android watch usually connect google cloud server through phone, and it is possible to directly connect via WiFi without phone. (https://developer.android.com/training/wearables/data-layer) Those are related to Wearable Data Layer API.
My questions are as follows. I'm not sure that android watch as client directly connects our server (with IP address and port number). If possible, could you give some sample codes for socket connection or URL for the codes? (I googled the related codes but I couldn't find them.)
I hope your many comments and welcome any comment. Thanks in advance.
Depending on the hardware you may or may not be able to connect directly (i.e. without relying on a phone) to your server.
For supported devices you can setup a network connection using the ConnectivityManager as described in this guide on Google's developer website.
Once you have established a network connection you should be able to connect to your server.
When i run my project on Emulator than localhost servery is working but when run on real Android phone than localhost server not found. So how can i access my localhost server from my real Android Device. I use XAMP server.
You cannot access localhost from your mobile device because the server is limited to your system only. In order to test the application you have to run the application on emulator so that it could find the server. Although there is a way...if you are creating a whole server that is backend and you have a network to which your mobile and system is connected then you can set your server to listen to a port on that network. I used NodeJs to accomplish that. You can search some tutorials for using NodeJs through which you can access you xampp server. You can also try AdonisJs which is a framework for NodeJs for a better approach. But keep in mind that you need a common network through which your system and your mobile device is connected. It is a bit complicated method but yes that can work. Accessing localhost directly from system to your mobile device is not possible..if you want to avoid learning NodeJs then you'll have to keep using emulator for the testing but learning something new is always amazing. So i would suggest you to learn NodeJs . Anyways you can avoid all the trouble and keep testing your application using your emulator. I hope this answer will help you :)
You should have told which ip you used running on emulator.
Your client on the android device should use the ip of the computer where your server is running on.
Android device and server computer in same WLAN.
If your computer and mobile are connected through same internet line then you can use ip of your computer instead of localhost can do the work.
You cannot access the local host server from a different node eventhough both nodes are connected to same network only way is that change the ip configuration of server to 0.0.0.0: so that you can access the server from any node just by typing the ip of the server followed by port no...
I am programming an Android app which connects to a TCP server running on my computer using sockets. This works perfectly fine as long as both my computer and my smartphone are connected to the Wi-Fi of my router.
I want it to also work when my computer and my phone are not connected to the Wi-Fi. Therefore I configured a Wi-Fi hotspot using hosted network on my computer. My smartphone recognizes the Wi-Fi and is able to connect to it. But now my app can't connect to the server running on my PC although I changed the code to the new IP that I got by using ipconfig on my PC.
I downloaded an app named "Fing" from the Google play store. The app shows all devices in a network. It does show my computer under the right IP address. I don't understand why my app can't connect to the server running on the PC.
On the one hand, I don't think that the problem is in the app's code, because it works on the router's Wi-Fi network. On the other hand, I doesn't seem to be a setup mistake either, because Fing is detecting my PC.
Do you have any ideas what the problem might be, or any other solution for my needs?
I actually wrote the TCP server myself using c#. I configured the Server to listen to all of my computers networkinterfaces usingIPAdress.IPv6Any. I also did configure it as dual mode socket so it can accept ipv4 and ipv6 connections. I will post the code when i am back home. So the TCP server also looks ok to me.
I have no networking background. I would like to apologize if the terms that I used in my question below are incorrect. Your help is appreciated.
1) Recently, I am developing an android app which involves google map api and xampp. I can access database on the phone browser(192.168.x.x:8080/folder/getdetail.php) when my android phone (4.1.2) is connected to my pc and used my pc's internet connection. But after I unplugged the usb from my pc and used wifi, I no longer can access the same link as mentioned above on my phone. May I know what is the problem and what tools or skills that I need to look for?
(2) If the above mentioned problem is solved, I am also looking forward on the way to make xampp to be accessible over the internet. For instance, my pc serves as a server at home and I can connect to the server and retrieve some data from the db when i am elsewhere.
P/S: My pc is using wireless internet connection.
Unfortunately there's too few information on your network and your pc. Let's assume you're using your Windows-PC and Phone on the same Network and you didn't change any web server settings and didn't move the XAMPP folder.
XAMPP is running an apache Server which is listening on TCP Port 80.
First you should check your firewall. Windows is using 3 different Profiles.
if you connect your phone and an additional network is set up with a different profile this could be the reason.
http://www.windows7library.com/blog/wp-content/uploads/2011/06/Network-and-Sharing-Center.jpg
If you want to access your XAMMP from the internet you should forward a TCP port to port 80 on your PCs LAN IP-Address.
http://en.kioskea.net/contents/280-nat-network-address-translation-port-forwarding-and-port-trigg
http: //en.wikipedia.org/wiki/Port_forwarding
But please only do that for testing purpose since outdated webservers/modules/scripts can actually harm your system. Use XAMPP only for development and testing.
My advice if you still want to do it forward some other port >10000 to your local port 80.
To access it you have to add the port to your url like this http: //127.0.0.1:8080/
I have an android application that talks to a server app running on grails (Groovy on Grails).
Android app basically establishes a connection with this address:
url="http://192.168.2.53:8080/tma/majBtm/androidToDesktop";
It all works fine when both the server and the android phone are connected in the same lan network.
Now the problem arises when I want the phone to talk to the server while the phone is outside the local network (I need it to use edge).
I came across VPN networks which I think might help me out. (the server has dynamic IP)
So what i did was go to dyndns.com and created a new hostname and have the app successfully run on the server. The host I created was - tmagrails.dyndns.com
How do I make my phone connect to this network? What changes am I supposed to make in order to get things working?
Also, I really want to know if this is the right approach. If not, is there any way to get things going for me?
Please advice.
First you need to set up port forwarding so that port 8080 is forwarded to your 192.168.2.53 ip address. A google search on your router model should tell you how to do this. If you want to make your app more secure you will also need to look at SSL and TLS While this won't garantee your app is secure it will stop the network traffic to your app being easily read if you were to access it from an open wifi hotspot.