I want to establish a socket connection between my mobile Android device and my PC, so that a string will be sent from my mobile phone to the Android application running on the PC.
See this tutorial for setting up a TCP connection, which is probably the one you're looking for, based on Java in the PC side which might be the server or the client:
Link
For more basic information about coding a client-server software you can also check this series of YouTube tutorials
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.
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'm creating an android app that should communicate with a PC application.
At first, I wrote the PC application as the server side of the connection (on Python),
but for some reasons I want to change it and to make the android app to the server side.
My problem is that the connection should be over the internet.
As I know, the android device (phone) is inside a private network of the cellular company,
which makes a problem to access the device over the internet.
Is there any way that the android device will be accessed directly from the internet?
Yes. IF you have access to TCP/UDP ports (they are not blocked on your private domain),
give a shot to Java Socket Programming.
Whether the server is mobile or PC is totally up to you.
If you need to learn about socket programming, the best place to start is this tutorial on official Oracle documentation website.
This is yet another learning by example tutorial.
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
i have an android device that has an app that i wrote installed on it. i wanted to send files from it to a windows pc by using bluetooth, and by adding code only to the app on the android phone.
the documentation on the android developers website says that one of the devices must be set up as a server to receive the request for a connection from the client side of the bluetooth connection.
if i try to initiate the connection from the android app side then that side will be the client, and the windows desktop pc will be the server side. is this possible if i am not writing any code for the windows pc and only using it's built in software that is made to handle the bluetooth hardware?
that would mean that the the included software on the windows pc is set in server mode alwasys waiting for a connection attempt from a bluetooth client, is this true?
Visit these links. Hope these help
http://www.forward.com.au/pfod/serialBluetoothConnections/index.html
http://blackmarketserver.com/blog/2010/11/23/bluetooth-file-transfer-between-android-2-2-and-windows-7
It is a possible duplicate of this question.
Please have a look
access of files on windows pc from android device, bluetooth?